Accessing DB2 from Eclipse [message #512299] |
Thu, 04 February 2010 10:35  |
Eclipse User |
|
|
|
I'm having some trouble getting a JDBC connection to my DB2 database from within Eclipse.
I am using:
- Eclipse Galileo 3.5.1
- DB2 9.5.2
- JDBC 3.0
- type 4 driver (com.ibm.db2.jcc.DB2Driver)
- Windows XP
Files db2jcc.jar, sqlj.zip, and db2jcc_license_cu.jar are listed under Referenced Libraries in the project.
This is my code:
try {
this.connection = DriverManager.getConnection(this.url, this.login, this.password);
}
catch (SQLException sql_excp) {
String msg = "Encountered SQLException on connect to url " + this.url + "."; //$NON-NLS-1$ //$NON-NLS-2$
this.logger.logp(Level.SEVERE, this.CLASS_NAME, METHOD_NAME, msg, sql_excp);
System.exit(16);
}
The database, Resume, exists in DB2 and I can query it with the DB2 Command Editor. The following two lines exist in my services file in Windows:
db2j_DB2 55000/tcp
db2c_DB2 50000/tcp
The error is:
4-Feb-2010 9:54:36 AM com.foo.resume2010.References connectToDatabase()
SEVERE: Encountered SQLException on connect to url jdbc:db2://server:50000/Resume.
com.ibm.db2.jcc.a.en: [3.52.95] Exception [Ljava.lang.Object;@145e044: Error opening socket to server {1} on port {2} with message: {3}. ERRORCODE=-4499, SQLSTATE=08001
at com.ibm.db2.jcc.a.ad.a(ad.java:319)
at com.ibm.db2.jcc.a.ad.a(ad.java:337)
at com.ibm.db2.jcc.t4.xb.a(xb.java:375)
at com.ibm.db2.jcc.t4.xb.<init>(xb.java:76)
at com.ibm.db2.jcc.t4.a.x(a.java:263)
at com.ibm.db2.jcc.t4.b.a(b.java:1809)
at com.ibm.db2.jcc.a.ib.a(ib.java:503)
at com.ibm.db2.jcc.a.ib.<init>(ib.java:459)
at com.ibm.db2.jcc.t4.b.<init>(b.java:330)
at com.ibm.db2.jcc.DB2Driver.connect(DB2Driver.java:197)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at com.foo.resume2010.References.connectToDatabase(References.j ava:336)
at com.foo.resume2010.References.<init>(References.java:206)
at com.foo.resume2010.ResumeSupportFileWriterReferencesPdf.writ eFile(ResumeSupportFileWriterReferencesPdf.java:162)
at com.foo.resume2010.ResumeFileGenerator.<init>(ResumeFileGenerator.java:116)
at com.foo.resume2010.ResumeFileGenerator.main(ResumeFileGenera tor.java:72)
Caused by: java.net.ConnectException: Connection timed out: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.ja va:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:525)
at com.ibm.db2.jcc.t4.y.run(y.java:34)
at java.security.AccessController.doPrivileged(Native Method)
at com.ibm.db2.jcc.t4.xb.a(xb.java:369)
... 14 more
This is my first time setting up DB2/JDBC/Eclipse on a computer in several years. This version of DB2 has some apparent changes to DB2 Version 8, which is what I was using previously. I've gone through the DB2 manuals but can't find my mistake there.
Can anyone see what I've done wrong?
--
Rhino
|
|
|
|
Powered by
FUDForum. Page generated in 0.03951 seconds