jdbc两种不同的实现
来源:互联网 发布:windows时间同步超时 编辑:程序博客网 时间:2024/05/16 13:41
//第一种,比较简单,对于任何的exception没做任何处理
Connection connection = DriverManager.getConnection(URL, user, password);
Statement statement = connection.createStatement();
ResultSet results = statement.executeQuery(sqlQuery);
while (results.next()){
... process query results ...
logSQLWarnings(results.getWarnings());
}
results.close();
statement.close();
connection.close();
//第二种,把exception写到log日志里,推荐!
try
{
Connection connection = DriverManager.getConnection(URL, user, password);
try
{
Statement statement = connection.createStatement();
logSQLWarnings(connection.getWarnings());
connection.clearWarnings();
try
{
ResultSet results = statement.executeQuery(sqlQuery);
logSQLWarnings(statement.getWarnings());
try
{
while (results.next())
{
... process query results ...
logSQLWarnings(results.getWarnings());
}
}
catch (SQLException e)
{
logSQLExceptions(e);
}
finally
{
results.close();
}
}
catch (SQLException e)
{
logSQLExceptions(e);
}
finally
{
statement.close();
}
}
catch (SQLException e)
{
logSQLExceptions(e);
}
finally
{
connection.close();
}
}
catch (SQLException e)
{
logSQLExceptions(e);
}
- jdbc两种不同的实现
- Singleton的两种不同实现方法.
- 线程的两种不同实现方式
- TabHost两种不同的实现方式
- 归并排序的两种不同实现
- 粒子特效(两种不同的实现)
- 实现axis2两种不同方式的客户端
- 实现两数 交换的三种不同编程方法。
- 实现axis2两种不同方式的客户端
- 实现axis2两种不同方式的客户端
- Java 计算器的实现(两种不同思路)
- 利用两种不同的数据结构实现双端栈
- 动画Animation两种实现方式的不同效果
- 命令模式(Command)的两种不同实现
- 多个按钮Button实现的两种不同写法
- 两种不同的Context
- 不同IE版本,引入不同的js文件。两种实现方式
- 两种不同的方法来实现一个两列布局
- 一个vb.net的用户登陆页面代码
- 备忘录模式(Memento Pattern)
- 用VB.NET轻松制作特效窗体
- 用VB.NET绘制GDI图形
- 如何轻松调整VB.NET控件
- jdbc两种不同的实现
- socket编程原理(二)
- 完整的VB.NET的语法解析程序
- VB.NET的新的面向对象能力
- VB.Net查找程序的前一个运行结果
- 用新VB.NET枚举提高效率
- 百万程序员的苦恼-选择VB.NET还是C#
- VB.Net开发的长内容自动分页功能
- VB.Net中应用ArrayList实例