JDBC_Statement

来源:互联网 发布:图片识别 python 编辑:程序博客网 时间:2024/06/08 17:47
Some notes about Statement in Jdbc

What is Statement  ?

Its a Factory in JDbc for ResultSet, you can see this.

JDBC :

            #Connection

                                  ##Statement

                                                           ###PrepareStement,CallableStatement

                                                                                                                                ####ResultSet

Can you Undestand this relationship  ?  its from big to small in jdbc.

@addBatch   // CRUD many sql

Example  : Statement   statment = connecntion.createStatement();

                   statement.addBatch(sql1);

                    statement.addBatch(sql2);

                    statement.addBatch(sql3);

                    statement.close();



@clearBatch();   //its for clear sql .

            Example :

Statement   statment = connecntion.createStatement();

                   statement.addBatch(sql1);

                    statement.addBatch(sql2);

                    statement.addBatch(sql3);

                    statement.clearBatch();   // clearBatch();;

                    statement.close();



@executeUpdate(), execute ,clearWarning();

     Example :  Statement stmt = conn.createStatement();
                        stmt. clearWarnings();

@getFetchSize();

Examle :System.out.println(stmt. getFetchSize());

@getGenercKeys();

Example : ResultSet rs = stmt.getGeneratedKeys();

@getMoreResulet();

Example :Statement stmt = conn.createStatement();
if(stmt.getMoreResults(Statement.CLOSE_ALL_RESULTS)){
    System.out.println("");
}

Note  : if you learned this all , that u can say you know jdbc about 20%。  Goodluck.

Iaprhan_Java   2016-6-18
1 0
原创粉丝点击