JDBC Using GetMetaData

Go back to: Code Samples
// prepare dummy query 
PreparedStatement WSps = WSc.prepareStatement 
    ("SELECT * FROM UnknownTable WHERE 1 = 0");
 
// query is not executed on the server - only prepared
ResultSetMetaData WSsmd=WSps.getMetaData();
int numcols = WSrsmd.getColumnCount();
...
int ctype = WSrsmd.getColumnType(n)
...
// Result column information has now been obtained.
// Note we also know the column ordering within the 
// table!




Like what you see? Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • LinkedIn
  • Reddit
  • StumbleUpon
  • Technorati
  • TwitThis

Book Content Copyright © 2009 by Prentice Hall PTR. All rights reserved. | Corporate Sponsor DataDirect Technologies.