JDBC resource binder, processes the query result set

Use of resources binder Binding attributes
The actual development is not recommended to write information to connect to the database's death Java program
          
//使用资源绑定器绑定属性配置
        ResourceBundle bundle = ResourceBundle.getBundle("jdbc");
        String driver = bundle.getString("driver");
        String url = bundle.getString("url");
        String user = bundle.getString("user");
        String password = bundle.getString("password");

 

Processing the query result set
The return type           method
int                   executeUpdate         (insert/delete/update)
ResultSet       executeQUery          (select)DQL
 
Result set ResultSet
// execute SQL 
            String = SQL "SELECT EMPNO, ename, SAL from EMP" ; 
            RS = stmt.executeQuery (SQL); // Method DQL is performed exclusively    

// process the query result set of 
            the while (rs.next ()) { / / cursor to row data
                 // fetch
                 // the JDBC in all indices starting at 1, not 0
                 // robust written to the field name (renamed after use is renamed) acquires 
                int EMPNO = RS. the getInt ( "EMPNO" ); 
                String ename = rs.getString ( "ename" ); 
                Double SAL = rs.getDouble ( "SAL" ); 
                System.out.println (EMPNO + ","+ename+","+will); 
            }

 

 
 
 

Guess you like

Origin www.cnblogs.com/promise-ljy/p/11530894.html