This week's giveaway is in the Programmer Certification (OCPJP) forum.
We're giving away four copies of Java Mock Exams (software) and have David Mayer on-line!
See this thread for details.
Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

ResultSetMetaData getTableName return empty String

Haroon idrees
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";

//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));
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!