List of usage examples for java.sql DatabaseMetaData bestRowTemporary
int bestRowTemporary
To view the source code for java.sql DatabaseMetaData bestRowTemporary.
Click Source Link
From source file:Main.java
public static void main(String[] args) throws Exception { Connection conn = getMySqlConnection(); System.out.println("Got Connection."); Statement st = conn.createStatement(); st.executeUpdate("drop table survey;"); st.executeUpdate("create table survey (id int,name varchar(30));"); st.executeUpdate("insert into survey (id,name ) values (1,'nameValue')"); DatabaseMetaData meta = conn.getMetaData(); // The '_' character represents any single character. // The '%' character represents any sequence of zero // or more characters. ResultSet rs = meta.getBestRowIdentifier(conn.getCatalog(), null, "survey", DatabaseMetaData.bestRowTemporary, false); while (rs.next()) { short actualScope = rs.getShort("SCOPE"); String columnName = rs.getString("COLUMN_NAME"); int dataType = rs.getInt("DATA_TYPE"); String typeName = rs.getString("TYPE_NAME"); int columnSize = rs.getInt("COLUMN_SIZE"); short decimalDigits = rs.getShort("DECIMAL_DIGITS"); short pseudoColumn = rs.getShort("PSEUDO_COLUMN"); System.out.println("tableName=survey"); System.out.println("scope=" + actualScope); System.out.println("columnName=" + columnName); System.out.println("dataType=" + dataType); System.out.println("typeName" + typeName); System.out.println("columnSize" + columnSize); System.out.println("decimalDigits" + decimalDigits); System.out.println("pseudoColumn" + pseudoColumn); }//w w w . j a v a 2 s. co m st.close(); conn.close(); }