随笔分类 -  JDBC

摘要:JDBC---作用:连接数据库!1.首先new 一个驱动进行注册,这里实在DriverManager中自动注册,我们只需要new一个实例出来就好.2.从DriverManager中取得连接Connection.3.取得连接后进行数据库操作.Statement, PreparedStatement, CallableStatement. 通过Connection的方法获得.4.读取数据库用的ResultSet, 之后扩展了游标可来回滚动的数据集,以及可更新的结果集.5.关于Transaction, 首先手动关闭Connection的AutoCommit, 然后直接transaction中的数据库 阅读全文
posted @ 2012-07-19 04:07 胡.杰 阅读(116) 评论(0) 推荐(0) 编辑
摘要:1.将Connection的Auto commit改成false.-->Connetion conn; conn.setAutoCommit(false);2.执行需要在这次交易中完成的操作语句.3.手动commit--->conn.commit();4.将Connection的Auto commit改回true.-->conn.setAutoCommit(true);5.抓Exception,如果出错.conn.rollback(); 并且conn.setAutocommit(true); 阅读全文
posted @ 2012-07-19 03:26 胡.杰 阅读(221) 评论(0) 推荐(0) 编辑
摘要:We have noticed that it's very inconvenient to use class Statement to execute aSQL statement.So we have another solution which is PreparedStatement.PreparedStatement ps=conn.prepareStatement("...... ");ps.setInt(... , ...);ps.setString(... , ....);....thenps.execute();--->It's e 阅读全文
posted @ 2012-07-19 00:54 胡.杰 阅读(134) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示