• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Junilu Lacar
  • Martin Vashko
  • Jeanne Boyarsky
  • Tim Cooke
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
  • salvin francis
  • Piet Souris


Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I am getting this exception when i am trying to
run a simple java program from command line.
at oracle.net.TNSAddress.ServiceAlias.initFromNVPair(Unknown Source)
at oracle.net.TNSAddress.ServiceAlias.initFromString(Unknown Source)
at oracle.net.resolver.AddrResolution.resolveAddrTree(Unknown Source)
at oracle.net.resolver.AddrResolution.resolveAndExecute(Unknown Source)
at oracle.net.ns.NSProtocol.establishConnection(Unknown Source)
at oracle.net.ns.NSProtocol.connect(Unknown Source)
at oracle.jdbc.ttc7.TTC7Protocol.connect(TTC7Protocol.java:1213)
at oracle.jdbc.ttc7.TTC7Protocol.logon(TTC7Protocol.java:209)
at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:249)
at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:365)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:260)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at TestJdbc.putData(TestJdbc.java:37)
at TestJdbc.main(TestJdbc.java:21)

The database i am using Oracle8i Enterprise Edition.
Here is my source code.
import java.sql.*;
public class TestJdbc
public static void main (String[] args)
TestJdbc t1 = new TestJdbc();
if (args.length <= 0)
int id = new Integer(args[0]).intValue();
String fname = args[1];
String lname = args[2];
System.out.println("rows inserted = " +
t1.putData(id, fname,lname));
public int putData(int id,
String fname,
String lname)
String url= "jdbc racle:thin:@naga";
String driver =
int rowsInserted = 0;
Connection con = null;
con = DriverManager.getConnection
String sql = "INSERT INTO Emp
PreparedStatement pstmt =
rowsInserted = pstmt.executeUpdate();
catch (ClassNotFoundException e)
System.out.println("The Exception
is . " + e.getMessage());
catch (SQLException e)
System.out.println("The SQL
Exception is . " + e.toString());
catch (Exception e)
System.out.println("The Exception
is . " + e.toString());
return rowsInserted;
Any suggestions I am rattling with this issue for the last couple of hours.
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which line of code is throwing the exception?
If it is the connection, then it may be your Connection URL:
you are missing the Oracle instance name and the port that instance is listening( make sure Oracle is listening at this port too! ).
Proper URL Format:

your code only specifies the server.
Sri Addanki
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jamie Robertson:
Thanks for the timely help and suggestion. It works.
There are 10 kinds of people in this world. Those that understand binary get this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!