Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

error with database connection

 
kavitha rama
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
We have ingres database and our front end is java and jsp. Our development work is on one server and database is on different server.
When I execute following code, I get run time exception as follows
ca.edbc.util.EdbcEx: Unable to establish connection due to communications error
I copied edbc.jar to lib directory. I don't understand what the problem is. Can somebody throw light on this please.
try {
Class.forName("ca.edbc.jdbc.EdbcDriver").newInstance();
}
catch (Exception ex) {
out.println("ClassNotFoundException: " +
ex.getMessage());
}
try {
con = DriverManager.getConnection(
"jdbc:edbc://ivie:II7/ivie::xxxx;UID=xxx;PWD=xxx");
}
catch(SQLException e)
{
out.println("connection could not be established " + e.toString() );
}
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looking at your code, it will still try to get a connection to the database even if the driver does not load. Is the Driver loading? ie is the Class.forName() line throwing an exception?
I know nothing about the ingres URL, but that looks like something to double check too. Sometimes it's worthwhile trying to make a connection in a stand alone application first to make sure you have these steps correct.
Also, you say you 'copied edbc.jar to lib directory', which one?
Dave
 
kavitha rama
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I don't get Exception at loading driver, so I guess it is loading driver but throws exception at getConnection. I got edbc.jar with ingres database, so I coped it to /j2ee/home/lib/edbc.jar.
What else I need to do? Please help
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Firstly I'd write a small stand alone application to test the database connection.
I'd also change your program so that it doesn't continue if it fails to load the Driver:

I'm assuming you're using the J2EE reference implementation from Sun to write your app? I'd recommend switching to something else, Tomcat is a (free) popular choice. I bring this up since I don't have the RI installed so I can't help you with the correct place to put the JAR file. Application servers behave differently to stand alone apps with respect to use of the classpath and where they get their code from. Hopefully someone else can help.
Dave
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looking over the Ingres support pages and the only part that didn't fir is this part of your JDBC URL:
jdbc:edbc://ivie:II7/ivie::xxxx;UID=xxx;PWD=xxx
I'm not saying it is the problem, but it doesn't appear to fit what the are saying should be on the URL.
Dave
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm moving this to JDBC...
 
kavitha rama
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for moving. Initially I didn't know that there was jdbc forum, so posted it in JSP, when i agian saw Jdbc forum, I posted it there too.
Thanks david, I'll follow ur code and try it.
Thanks for the information.
We r using oracle 9iAS, as we are using other jar files as well and they are working, I don't think problem is with placing jar file in right place.
Anyway i'll give a try. Thanks
 
kavitha rama
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi David,
I executed code to see if it fails to load driver, but it doesn't complaint about loading driver, it loads successfully and complaints about getConnection as follows
"Unable to establish connection due to communications error"
I checked documentation from the link forwarded by you, syntax for URL was correct. Thanks for help.
 
kavitha rama
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks David. I got it working finally. I checked support site for ingres as you suggested, Problem was jdbc server was not running and also port number was wrong. Thanks for the help
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic