Code example for Statement

Methods: closeexecuteexecuteQuery

0
    throws java.sql.SQLException { 
 
        int                cols;
        java.sql.Statement stmt = conn.createStatement();
 
        stmt.execute("CREATE temp TABLE MYTABLE(COL1 INTEGER,COL2 VARCHAR);");
        stmt.execute("INSERT INTO MYTABLE VALUES    (1,'test1');");
        stmt.execute("INSERT INTO MYTABLE VALUES(2,'test2');");
 
        java.sql.ResultSet rs = stmt.executeQuery("select * from MYTABLE");
        java.sql.ResultSetMetaData meta = rs.getMetaData();
 
        cols = meta.getColumnCount();
 
        rs.close();
        stmt.close();
 
        return cols;
    } 
 
    public static void main(String[] args) throws Exception {
Stop searching for code, let great code find you!  Add Codota to your java IDE