Sorry, I posted this on google but I didnt see it on the mailing list.
I am proably lacking something simple, but I found no reference in my
search for a fix.
I can connect with both the stable and development libraries to my
database and do selects and inserts. However, my select all appear
empty and result in blank strings. I can getmetadata and get the
correct columns count even get the right number of rows returned, I
even get the right length of rs.getString(x).length(). But as soon as
I system out, i just get "".
any help?
try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
}catch(InstantiationException e){
System.out.println(e.getMessage());
}catch(ClassNotFoundException e){
System.out.println(e.getMessage());
}catch(IllegalAccessException e){
System.out.println(e.getMessage());
}
Connection conn =
DriverManager.getConnection("jdbc:mysql://host/qadata?user=user&password=pass");
Statement stmt = conn.createStatement();
//stmt.executeUpdate("insert into
xxxxx(name,dir_id,run_on) values ('XXXXX','ZZZZZ', SYSDATE())"); //
works!
ResultSet rs=stmt.executeQuery("select * from qarun");
ResultSetMetaData rsdata=rs.getMetaData();
System.out.println(rsdata.getColumnCount());
System.out.println(rsdata.getColumnName(2));
int x=0;
while(rs.next()){
String test=rs.getString(2);
System.out.println("=="+rs.getString(1)+"<<"+x++);
}
rs.close();
stmt.close();
conn.close();
}catch(SQLException e){
System.out.println(e.getMessage()+"11111111");
}
gives
3
==12<<0
>>> ==14<<1
>>> ==12<<2
>>> ==12<<3
>>> ==8<<4
>>> ==8<<5
>>> ==8<<6
>>> ==8<<7
>>>
| Thread |
|---|
| • Confouned by empty string | Ricardo Bosch | 18 Mar |