Originally posted by Herroin:
Anyone have any idea how to retrieve data from db2 using j2ee ? I kind of clueless. I am doing a web services for J2EE using rational and db2 as my database
Hi, I only know how to query from from a local ODBC DSN
Go Start>Run>type "odbcad32"
(This is to open your Open DataBase Connectivity 32 bit Adminstrator panel.)
Add the datasource into the System DSN (Data Source Name).
From java, you code like this:
(Just a skeleta form)
code:
import javax.sql.*; //must
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch (ClassNotFoundException e) {
System.out.println("anything thing here");
}
Connection connection1 = DriverManager.getConnection("jdbc:odbc:dataBaseName");
//Replace dataBaseName with the name you saved in your system DNS
Connection connection1 = null;
try {
connection1 = DriverManager.getConnection("jdbc:odbc:dataBaseName");
//Do your query here.
}
finally {
if (connection1 != null)
connection1.close();
}
Edited: Due to the stupid smiley...