Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ResultSetMetaData getTableName return empty String

 
Haroon idrees
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried my different test but still not returning table name I set resultsetmetaoptions in difrent ways kindly help below in my code.I checked this code on 11g and 10g express edition
i use oracle jdbc driver which available for 11g

String driver = "oracle.jdbc.driver.OracleDriver";

Class.forName(driver);
//String jdbcUrl = "jdbcracle:thin:@localhost:1521:xe";
String jdbcUrl = "jdbcracleci:@localhost:1521:xe";
// String jdbcUrl = "jdbcracleci:@localhost:1521:xe?ResultSetMetaDataOptions=1"; thrown exception invalid sid
// String jdbcUrl = "jdbcracleci:@localhost:1521:xe;ResultSetMetaDataOptions=1"; thrown exception invalid sid

Properties p=new Properties();
java.util.Properties info = new java.util.Properties();
info.put ("user", "******");
info.put ("password","******");
info.put ("ResultSetMetaDataOptions",1);
Connection conn = DriverManager.getConnection(jdbcUrl,info);

Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM product");
ResultSetMetaData rmd = rs.getMetaData();

for (int i = 1; i <= rmd.getColumnCount(); i++) {
System.out.println("column MetaData ");
System.out.println("column number " + i +" = " +rmd.getColumnName(i));

// get the designated column's table name.
}
System.out.print("table name"+ rmd.getTableName(1) +" schema "+rmd.getSchemaName(1) +" "+ rmd.getCatalogName(1));
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic