Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Help Formulating A database url for jdbc

2 views
Skip to first unread message

Steve

unread,
Aug 16, 2001, 4:14:44 PM8/16/01
to
Hi;

I am trying to connect to an Oracle 8i database running on Windows NT
with a jdbc test program I made.

I made the test program a while ago, so I know the code is fine. I
alway have trouble getting the
database url for correct so I think this is the problem.

The error message I got when trying to connect was:
================================================================================================
C:\Projects\usaidb>java "TestBean"
java.sql.SQLException: Io exception: Connection
refused(DESCRIPTION=(TMP=)(VSNNUM=135294976)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4))))
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java)
at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java)
at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java)
at java.sql.DriverManager.getConnection(DriverManager.java:517)
at java.sql.DriverManager.getConnection(DriverManager.java:177)
at com.valueoptions.db.DbBean.connect(DbBean.java:83)
at TestBean.main(TestBean.java:29)
==================================================================================================


The database url I used was:
jdbc:oracle:thin:@10.1.1.64:1521:oracle"

"10.1.1.64" is the ipaddress of the server

Here is the function call for my connection object:

db.connect(dbUrl, dbUser, dbPassword);


Here is that function in the connection object:

/*****************************************************************************/
public boolean connect(String DbUrl,
String DbUser,
String DbPassword)
throws ClassNotFoundException, SQLException
{
if ( (DbUrl.trim().length() == 0) || (DbUser.trim().length()
== 0) ||
(DbPassword.trim().length() == 0) )
{
throw new SQLException("Db: Required input parameters were
not provided: DbUrl, DbUser, DbPassword");
} // end if

this.DbUrl = null;
this.DbUser = null;
this.DbPassword = null;

Class.forName(getDbDriver());

DbConn = DriverManager.getConnection(DbUrl, DbUser,
DbPassword);
// setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);

this.DbUrl = DbUrl;
this.DbUser = DbUser;
this.DbPassword = DbPassword;

return(true);
}


/*****************************************************************************/


Any ideas about things I should check?

thanks in advance

Steve

Yong Luo

unread,
Aug 16, 2001, 4:35:02 PM8/16/01
to
have you tried to remove those 3 lines of this.XXXXXX=null?

Michael Kreher

unread,
Aug 16, 2001, 6:23:29 PM8/16/01
to
"Steve" <steves...@yahoo.com> schrieb im Newsbeitrag
news:6f8cb8c9.01081...@posting.google.com...

Hi Steve,

Oracle has thrown an error of type Listener Error with the error-number
ORA-12505.
In the Oracle-Documentation you can read this to that error-number:

[...]

ORA-12505: TNS: listener could not resolve SID given in connect
descriptor.
Cause:
The SID in the CONNECT_DATA was not found in the listener's tables.
This error will be returned if the database instance has not registered
with thelistener;
the instance may need to be started.

Action:
Check to make sure that the SID specified is correct.
The SIDs that are currently registered with the listener can be obtained
by typing
"LSNRCTL SERVICES <listener name>". These SIDs correspond to
SID_NAMEs in TNSNAMES.ORA, or DB_NAMES in the initialization file.

[...]

So I think that your SID is not "oracle" (maybe the common string "orcl" is
the correct one and should do the work). Another possibility is, that the
database is not started up. Try to connect to Oracle via SQL*PLUS to check
if the database is accessible.

Bye.

Michael


Steve

unread,
Aug 17, 2001, 6:29:17 AM8/17/01
to
"Michael Kreher" <kre...@rcs.urz.tu-dresden.de> wrote in message news:<9lhgsv$4ae$1...@rks1.urz.tu-dresden.de>...

>
> Hi Steve,
>
> Oracle has thrown an error of type Listener Error with the error-number
> ORA-12505.
> In the Oracle-Documentation you can read this to that error-number:

I have the oracle 8i _client_ (only) installed on my pc. Where can I
find the oracle documentation that explains what the error codes are
on my comptuer?

Is there a web site that lists these codes and their definitions? I
have a java page I keep. Such a link would be very useful.



> [...]
>
> ORA-12505: TNS: listener could not resolve SID given in connect
> descriptor.
> Cause:
> The SID in the CONNECT_DATA was not found in the listener's tables.
> This error will be returned if the database instance has not registered
> with thelistener;
> the instance may need to be started.
>
> Action:
> Check to make sure that the SID specified is correct.
> The SIDs that are currently registered with the listener can be obtained
> by typing
> "LSNRCTL SERVICES <listener name>". These SIDs correspond to
> SID_NAMEs in TNSNAMES.ORA, or DB_NAMES in the initialization file.
>
> [...]
>
> So I think that your SID is not "oracle" (maybe the common string "orcl" is
> the correct one and should do the work). Another possibility is, that the
> database is not started up. Try to connect to Oracle via SQL*PLUS to check
> if the database is accessible.

I did connect by sql+ about an hour before. When I get into work I'll
try again right before I try my program......its a new database :).

I'm still learning jdbc......I know SID is an id, but what exactly
does the abbreviation expand to? Where do I type commands that the
error message above advises me to type? Is it enough to just go to
tnsnames.ora ?

THanks for the quick response :)

Michael Kreher

unread,
Aug 17, 2001, 5:18:17 PM8/17/01
to
"Steve" <steves...@yahoo.com> schrieb im Newsbeitrag
news:6f8cb8c9.01081...@posting.google.com...

> I have the oracle 8i _client_ (only) installed on my pc. Where can I


> find the oracle documentation that explains what the error codes are
> on my comptuer?
>
> Is there a web site that lists these codes and their definitions? I
> have a java page I keep. Such a link would be very useful.
>

Hello Steve

The online documention sets for Oracle products are available on the website
of the OTN (Oracle Technology Network) at http://otn.oracle.com/.
I believe that you must be a member of the OTN, if you will access the
ressources of this site, but I am not shure. Any way, the OTN-Membership is
free.

The Oracle documention structure is quit complex. So i give you the direkt
link to the document from which you can jump to the different chapters with
the Oracle 8i error messages:
http://otn.oracle.com/docs/products/oracle8i/doc_library/817_doc/server.817/
a76999/toc.htm

>
> I did connect by sql+ about an hour before. When I get into work I'll
> try again right before I try my program......its a new database :).
>
> I'm still learning jdbc......I know SID is an id, but what exactly
> does the abbreviation expand to?

Well, I am not an expert for Oracle adminstration things. But I believe SID
stands for Service Identifier. It's the name of the database (specified by
DB_NAME in the file init.ora on the server side) or an aliase for the
database (specified in the file tnsnames.ora on the client side).

> Where do I type commands that the error message above advises me to type?

You type the commands in the normal command-shell (prompt) of your operating
system. The black screen, you know...? ;-)

> Is it enough to just go to tnsnames.ora ?

Can't say it. Simply look in the file and search for strings which can be
the SID and try... Maybe the SID can also be determined by a look in the
file listener.ora.
Sorry, but here I can't help you a lot. It's not my field of knowledge...

Bye

Michael


0 new messages