I have a problem with JDBC / ORACLE
I write :
DriverManager.getconnection("jdbc:oracle:thin:@152.9.102.137:1521:dbname","login","password")
But i don't know what is exactly "dbname" ?
And i get the following error:
The error message we are getting are:
java.sql.SQLException: Connection refused
at oracle.jdbc.dbaccess.DBError.check_error(DBError.java:223)
at oralce.jdbc.driver.OracleConnection.(init)(OracleConnection.java:100)
at
oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:146)
at java.sql.DriverManager.getConnection(DriverManager.java:91)
at java.sql.DriverManager.getConnection(DriverManager.java:134)
at sqltest.main(sqltest.java:10)
Could you explain me what mean "host:port:dbname" ... ?
It will be very cool, it is for a traning periode .
Thank you very much.
Best Regards.
Gilles TOST, (Studient).
>I have a problem with JDBC / ORACLE
>
>I write :
>
>DriverManager.getconnection("jdbc:oracle:thin:@152.9.102.137:1521:dbname","login","password")
>
>But i don't know what is exactly "dbname" ?
>
>And i get the following error:
>
>The error message we are getting are:
> java.sql.SQLException: Connection refused
> at oracle.jdbc.dbaccess.DBError.check_error(DBError.java:223)
>at oralce.jdbc.driver.OracleConnection.(init)(OracleConnection.java:100)
> at
>oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:146)
> at java.sql.DriverManager.getConnection(DriverManager.java:91)
> at java.sql.DriverManager.getConnection(DriverManager.java:134)
> at sqltest.main(sqltest.java:10)
if you catch the SQLException you can get the error code and error
message returned by Oracle, which will make it easier to debug.
try {
// whatever
} catch (SQLException e) {
System.err.println("Error code: " + e.getErrorCode());
System.err.println("Error message: " + e.getErrorMessage());
}
You can then look up the error in 'Oracle Server Messages' or use the
oerr utility.
>Could you explain me what mean "host:port:dbname" ... ?
host = host address (ip number) or host name
port = TCP/IP port number of TNSLISTENER service on the host you're
connecting to.
dbname = SID (Oracle Server ID)
Look in $ORACLE_HOME/network/admin/tnsnames.ora (or find tnsnames.ora
on your system) and look for a line with (SID = 'your SID here').
Usually the SID is 'orcl' by default.
>It will be very cool, it is for a traning periode .
I can recommend 'Understanding SQL*NET'.
Tom