Database operation is performed using JDBC, which is divided into the following steps: 1. Load drive format: Class.Forname (
2. Dissipate the data source. CONNECTION con = 0.GETCONNECTION (
3. Execute statement stmt = con.creatStatement (); ---- Execute Storage Procedure: Stmt.execute (
Commonly used: while (rs.next ()) {} utilization. PrepairedStatement Advantages: No need to be generated, as long as the parameters are modified, EG prepairedState pstmt1 pstmt1 = con.prepairedStatement ("SELECT * from TableName WHERE A =? And b =? ") pstmt1.setstring (Text1.getText, Text2.getText) ResultSet RS = PSTMT1.EXECUTEQUERY ();
Using ResultSetMetadata to get the number of fields in the data table, type, etc., you can use the result of getMetadata (), and the return result is saved with the ResultSetMetadata object. EG RESULTSET RS = Stmt.getResultSet () ResultSetMetadata RSMD = rs.getMetadata (); // Field Number, INT ColuMecount = rsmd.getColumnCount () for (i = 1; i <= columncount; i ) {system.out.println (RSMD.GetClumnname ())
}
// The above is for reference only,