Meaningless Drivel is fun!*
The moose likes JDBC and the fly likes How I can Connect  DB2 OS/390, database. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How I can Connect  DB2 OS/390, database." Watch "How I can Connect  DB2 OS/390, database." New topic
Author

How I can Connect DB2 OS/390, database.

Arockiaraj Swaminathan
Greenhorn

Joined: Jan 20, 2001
Posts: 12
Hai Friends !

1. I am trying to connect the DB2 os/390 database.
Can any one help me to get connect with the DB2.
If possible attach sample code.

Thanks in Advance.

------------------
S Arockiaraj


S Arockiaraj
Travis Gibson
Ranch Hand

Joined: Oct 17, 2000
Posts: 100
Here is sample code for connection to a Sample 390/DB2 (Employer) database:

String url = "jdbc:db2:SCIFDB2T";
Connection con;
Statement stmt;
String query = "select * from EMPLOYER " +
" where RECORD_NUM = 1011";

try {
Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");
} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
con = DriverManager.getConnection(url,
"user", "password");
stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(query);
}
stmt.close();
con.close();
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}
}
Enjoy..If you need more information on JDBC go to http://java.sun.com/docs/books/tutorial/jdbc/index.html

------------------
Regards,
Travis M. Gibson, SCJP
Java Developer
www.travismgibson.com
travis@travismgibson.com


Regards,<BR>Travis M. Gibson, SCJP<BR>Java Developer<BR>www.travismgibson.com<BR>travis@travismgibson.com
Arockiaraj Swaminathan
Greenhorn

Joined: Jan 20, 2001
Posts: 12
Hai Travis Gibson !
Thanks for yr instant reply.
One more thing I wanted to clear.
1 Where do I get "COM.ibm.db2.jdbc.app.DB2Driver" this
driver ? and Weather it has to be downlaoded or we have to set calsspath. I searched thru IBM Site, but I could not get either downloads or any JAR files.
Please Let me Know .
I am total zero in DB2 Mainframe side.
My Mainframe Pc Host is in Denmark. I am in India. I wanted to connect the DB2, and generate some reports,is it possible.
2. I wanted to connect remote DB2. In that case How do I know the Machine name, Port Number, database Name in the Mainframe Pc.
3.I wanted to put my application into the Webserver, Servlet.So that n number of clients can view the report.
Is it Possible ? yes or No ?
If yes Do I need any Middlewares, if so Let me know ?
I hope that I have explained my requirements Clearly !
Thanks in Advance !
Originally posted by Travis Gibson:
Here is sample code for connection to a Sample 390/DB2 (Employer) database:

String url = "jdbc:db2:SCIFDB2T";
Connection con;
Statement stmt;
String query = "select * from EMPLOYER " +
" where RECORD_NUM = 1011";

try {
Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");
} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
con = DriverManager.getConnection(url,
"user", "password");
stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(query);
}
stmt.close();
con.close();
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}
}
Enjoy..If you need more information on JDBC go to http://java.sun.com/docs/books/tutorial/jdbc/index.html


------------------
S Arockiaraj
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How I can Connect DB2 OS/390, database.