小白学java-基础篇(数据库编程)

1、Connection类:
a、Statement creatStatement() throws SQLException创建一个Statement对象;
b、Statement creatStatement(int resultSetType,int resultSetConcurrency) throws SQLException创建一个Statement对象,该对象将生成具有给定类型和并发性的resultSet对象;
c、PreparedStatement preparedStatement(String sql) throws SQLException创建一个PreparedStatement类型的对象;
d、PreparedStatement preparedStatement(String sql,int resultSetType,int resultSetConcurrency) throws SQLException创建一个PreparedStatement类型的对象,该对象将生成具有给定类型和并发性的resultSet对象;
e、CallableStatement prepareCall(String sql) throws SQLException创建一个CallableStatement对象,此对象专门用于调用数据库的存储过程;
f、CallableStatement prepareCall(String sql,int resultSetType,int resultSetConcurrency) throws SQLException创建一个CallableStatement对象,该对象将生成具有给定类型和并发性的resultSet对象;
g、DatabaseMetaData getMetaData() throws SQLException得到数据库的元数据;
h、void setAutoCommit(boolean autoCommit) throws SQLException设置数据库的自动提交,与事物有关;
i、boolean getAutoCommit() throws SQLException判断数据库是否可以自动提交,与事物有关;
j、Savepoint setSavepoint() throws SQLException设置数据库的恢复点,与事物有关;
k、Savepoint setSavepoint(String name) throws SQLException为数据库的恢复点指定一个名字,与事物有关;
l、void rollback() throws SQLException设置数据库回滚,与事物有关;
m、void rollback(Savepoint savepoint) throws SQLException设置数据库回滚的保存点,与事物有关;
n、void commint() throws SQLException提交操作,与事物有关;
o、boolean isClosed() throws SQLException判断连接是否关闭;
p、void closed() throws SQLException关闭连接;

2、更新操作Statement接口:
a、int executeUpdate(String sql) throws SQLException执行数据库的更新操作,返回更新的记录数;
b、ResultSet executeQuery(String sql) throws SQLException执行数据库的查询操作,返回结果集对象;
c、void addBatch(String sql) throws SQLException增加一个待执行的SQL语句;
d、int[] executeBatch() throws SQLException批量执行SQL语句;
e、void closed() throws SQLException关闭Statement操作;
f、boolean] execute() throws SQLException执行SQL语句;

3、处理大数据对象,用PreparedStatement接口;
调用存储过程用CallableStatement接口;
事务处理;
使用元数据处理数据库;
!!!日后深入学习

猜你喜欢

转载自blog.csdn.net/qq_29070549/article/details/79552369
今日推荐