File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Everytime getting an empty ResultSet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Everytime getting an empty ResultSet" Watch "Everytime getting an empty ResultSet" New topic

Everytime getting an empty ResultSet

Souvik Das

Joined: Oct 11, 2007
Posts: 15
I want to access DB2 which is connected to AS400. So i am using driver which i have got ftom jt400.jar. As i am using JDK 1.4, i have used jtopen 4.8 version for getting this jar.

My problem is: I have established a connection. But when my query run,it does returns a resultset which is empty but not null. It has all the metadatas but it does not have any value.Everytime giving "false" value.

Please help me.

My Code is:
private Connection getP400Connection() throws Exception{
Connection conn= null;

P400Config = loadPropertyFile(P400PropertyFile);
String driverName = P400Config.getProperty("drivername"); // Getting driver from properties file
System.out.println("Driver Name : "+driverName);
Class.forName(driverName); // Loadding the Driver
//DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
// Create a connection to the database
String serverName = P400Config.getProperty("servername"); // Getting servername,portnumber
String portNumber = P400Config.getProperty("portname"); // sid,url from properties file
String sid = P400Config.getProperty("sid");
String url = P400Config.getProperty("url")+serverName+":"+portNumber +":"+sid;
System.out.println("URL :"+url);
conn = DriverManager.getConnection(url,P400Config.getProperty("username"),P400Config.getProperty("pwd"));// Creating the Connection Object
catch(Throwable th)

return conn;

private void getDataFromP400() throws Exception{
String query = null;
Statement stmt = null;
ResultSet rs = null;
query = "select ZLOTNUM from itgdta.zlot where VALIDFLAG ='F'";
//query = "select * from itgdta.zpld,itgdta.zlot where itgdta.zpld.zplpfx = 'PL' and itgdta.zpld.zsbucode > 'a'";
Connection conn = getP400Connection();
stmt = conn.createStatement();
rs = stmt.executeQuery(query);
//System.out.println("Boolean value : "+stmt.execute(query));
if(rs != null){
System.out.println("Some data is Here");
ResultSetMetaData rsMeta = rs.getMetaData();
System.out.println("Total MetaData "+ rsMeta.getColumnCount());
for(int i=1;i<=rsMeta.getColumnCount();i++){
System.out.println("i = "+i+" Meta "+rsMeta.getColumnName(i) +" "+rsMeta.getColumnLabel(i));
System.out.println(" Why?? ";
strClientName = rs.getString("ZLOTNUM");
System.out.println("Client Name : "+strClientName);

System.out.println("Query Failed ........");

}catch(Exception e){
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
Have you run the query directly against the DB? Does it return any data then?
Souvik Das

Joined: Oct 11, 2007
Posts: 15
Originally posted by Ulf Dittmer:
Have you run the query directly against the DB? Does it return any data then?

Thanks for support. Actually user id what I was using was wrong.
I agree. Here's the link:
subject: Everytime getting an empty ResultSet
jQuery in Action, 3rd edition