Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / September 2006

Tip: Looking for answers? Try searching our database.

Connection refused

Thread view: 
Monica - 27 Sep 2006 19:58 GMT
Hello,

I hope someone can help.  Please let me know if this is the wrong group
for my question.

I am new to java, jsp and oracle, so I ask that you please be patient.
I am attempting to create a context-param in web.xml for my connection
string, so that when I need to change the string I will only need to do
it in one place instead of 10+ files.  When I perform a pooled
connection from within my code, the connection works correctly.  For
example:

                  .....
      PooledConnection conn = null;
      Connection conn2 = null;
      try
      {
         OracleConnectionPoolDataSource ocpds= new
OracleConnectionPoolDataSource();
         ocpds.setURL("jdbc:oracle:thin:@<myservername>:1526:ORCL");
         ocpds.setUser("user");
         ocpds.setPassword("pass");

         conn = ocpds.getPooledConnection();
         conn2 = conn.getConnection();
                     ......

However, I receive an error message when I try to access my connection
string from the web.xml.  Here is my code within my web.xml:

  .....
 <context-param>
   <param-name>dbConnectionString</param-name>

<param-value>"jdbc:oracle:thin:@<myservername>:1526:ORCL"</param-value>
 </context-param>
 <context-param>
   <param-name>databaseUser</param-name>
   <param-value>"user"</param-value>
 </context-param>
 <context-param>
   <param-name>databasePassword</param-name>
   <param-value>"pass"</param-value>
 </context-param>
  .....

Here is how I am calling the connection string from the web.xml into my
file:

                 .....
      PooledConnection conn = null;
      Connection conn2 = null;
      try
      {
         OracleConnectionPoolDataSource ocpds= new
OracleConnectionPoolDataSource();
         String dbConnectionString =
getServletContext().getInitParameter("dbConnectionString");
         String databaseUser =
getServletContext().getInitParameter("databaseUser");
         String databasePassword =
getServletContext().getInitParameter("databasePassword");

         ocpds.setURL(dbConnectionString);
         ocpds.setUser(databaseUser);
         ocpds.setPassword(databasePassword);

         conn = ocpds.getPooledConnection();
         conn2 = conn.getConnection();
                      .....

The error I receive is:

SQLException: Io exception: Connection
refused(DESCRIPTION=(TMP=)(VSNNUM=168821504)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4))))

I have tried changing <myservername> to the ip address, but I get the
same error.

If anyone has any idea how to make this work, or if you need more
information, please let me know.

Thanks in advance,
Monica
Michael Rauscher - 27 Sep 2006 23:11 GMT
Monica schrieb:
>          ocpds.setURL("jdbc:oracle:thin:@<myservername>:1526:ORCL");

AFAIK the standard port of the listener is 1521. Perhaps that's the problem.

Of course, the listener must be running :)

Bye
Michael
Monica - 28 Sep 2006 13:49 GMT
> Monica schrieb:
> >          ocpds.setURL("jdbc:oracle:thin:@<myservername>:1526:ORCL");
[quoted text clipped - 5 lines]
> Bye
> Michael

Michael,

Thank you for your response.  I tried changing the port to 1521, but I
got this error:

SQLException: Io exception: The Network Adapter could not establish the
connection

And since the files that are hard coded with the connection string
work, I can't figure out what the problem might be.  I would also
assume that since those files work that the listener is running.

Any other ideas out there?

Thanks,
Monica
Monica - 28 Sep 2006 17:43 GMT
> Monica schrieb:
> >          ocpds.setURL("jdbc:oracle:thin:@<myservername>:1526:ORCL");
[quoted text clipped - 5 lines]
> Bye
> Michael

Thanks for the reply.  I tried changing the port to 1521, but got this
error:

SQLException: Io exception: The Network Adapter could not establish the
connection

I confirmed with the DBA that the port we use is 1526 and that the
listener is running.  Any other ideas out there about this?  All
suggestions appreciated!!

Thanks,
Monica
David Harper - 28 Sep 2006 19:19 GMT
> Hello,
>
[quoted text clipped - 22 lines]
>          conn2 = conn.getConnection();
>                       ......
[SNIP]
> The error I receive is:
>
> SQLException: Io exception: Connection
> refused(DESCRIPTION=(TMP=)(VSNNUM=168821504)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4))))

Caveat: I'm a MySQL user, I'm not an Oracle guru!  I simply googled for
the Oracle error code 12505 which appears in the message of your
SQLException.  This error code may offer a clue that you can follow up.

Error 12505 appears to mean: "TNS:listener could not resolve SID given
in connect descriptor".

Maybe this will ring a bell with one of the resident Oracle experts
around here?

David Harper
Cambridge, England
Michael Rauscher - 28 Sep 2006 19:26 GMT
David Harper schrieb:
>> Hello,
>>
[quoted text clipped - 34 lines]
> Error 12505 appears to mean: "TNS:listener could not resolve SID given
> in connect descriptor".

Sure. This usually means that the service id (ORCL here) is wrong. Your
answer should help Monica a lot :)

Bye
Michael
Monica - 29 Sep 2006 13:21 GMT
Thank you both for your responses.

Sometimes I feel like a complete idiot.  I figured out the problem.

The connection string I was using in the web.xml was:

<param-value>"jdbc:oracle:thin:@<myservername>:1526:ORCL"</param-value>

 </context-param>
 <context-param>
   <param-name>databaseUser</param-name>
   <param-value>"user"</param-value>
 </context-param>
 <context-param>
   <param-name>databasePassword</param-name>
   <param-value>"pass"</param-value>
 </context-param>

I removed the quotes from around the string, the username and the
password, and it now works.  Thanks again for all your help.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.