Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Everytime getting an empty ResultSet

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I want to access DB2 which is connected to AS400. So i am using com.ibm.as400.access.AS400JDBCDriver 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 rs.next() giving "false" value.

Please help me.

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

try
{
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)
{
th.printStackTrace();

}
return conn;
}


private void getDataFromP400() throws Exception{
String query = null;
Statement stmt = null;
ResultSet rs = null;
try{
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?? "+rs.next());
while(rs.next()){
strClientName = rs.getString("ZLOTNUM");
System.out.println("Client Name : "+strClientName);
}

}else{
System.out.println("Query Failed ........");
}

}catch(Exception e){
e.printStackTrace();
}finally{
rs.close();
stmt.close();
}
}
 
Rancher
Posts: 43028
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you run the query directly against the DB? Does it return any data then?
 
Souvik Das
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
Thanks
 
reply
    Bookmark Topic Watch Topic
  • New Topic