• 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 ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Java DB2 Type 4 connection problem

 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am testing DB2 datasource configuration through a jsp for a remote DB2 database for Type 4.

I have done DB2 datasource config in WSAD 5.1 test server

Database Name: MYDB
Server Name :MYDB.domain.com
Port Number :446
URL : jdbc:db2://MYDB.domain.com:446/MYDB
JNDI Name : jdbc/MYDB


Test.jsp
--------
<BODY>
<%try {
Class.forName("com.ibm.db2.jcc.DB2Driver");
javax.naming.InitialContext ctx = new javax.naming.InitialContext();
%>

<% javax.sql.DataSource ds = (javax.sql.DataSource)ctx.lookup("jdbc/MYDB"); %>

<% java.sql.Connection connection = ds.getConnection("myuser","mypass"); %>
<%
connection.close();
} catch (Exception e) {
%>
Error : <%=e%>
<%
}
%>
</BODY>



But i get error "Connection failed.Server not responding". I am able to ping the Server.



Can some body pls help me and tell what I am missing or whats wrong.
Do i need to modify web.xml or web-bind.xml ?
Thanks in advance.
 
author & internet detective
Posts: 40198
816
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ratan,
Are you able to access db2 through the command line from your machine to the remote server?
 
Ratan Kumar
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Thanks for the response.

I am getting the following error
"CLI0615E Error receiving from socket, server is not responding. SQLSTATE=08S01"

I have verified..I have able to ping and get reply from the db2 server.

Also I have tested JDBC connection through Configuration assistant. It worked fine.

Also the following jsp works fine

<BODY>
<%try {
Class.forName("com.ibm.db2.jcc.DB2Driver");
String url= "jdbc:db2://MYDB.domain.com:446/MYDB";

%>


<% java.sql.Connection connection = java.sql.DriverManager.getConnection(url,"myuser","mypass");

%>
<%
connection.close();
} catch (Exception e) {
%>
Error : <%=e%>
<%
}
%>
</BODY>



Kindly help pls. How do i test Db2 connection through command line?

Thanks in advance
[ January 25, 2007: Message edited by: Ratan Kumar ]
 
Jeanne Boyarsky
author & internet detective
Posts: 40198
816
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The fact that the second JSP works means that the network is not the problem. So you don't need to test through the command line to verify this.

It looks like something is wrong with the datasource. When I used WSAD, we had to define the userid/password on the server configuration rather than in the code. You might want to try setting two new properties at the bottom of the datasource screen: userid and password.

I'm going to move this to our IBM/WebSphere forum as it is more about WSAD setup than general JDBC.
 
permaculture is giving a gift to your future self. After reading this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic