public void doQueries() throws MyException{
// First try-with-resources.
try ( Connection con = DriverManager.getConnection( dataSource ) ;
PreparedStatement s1 = con.prepareStatement( updateSqlQuery ) ;
PreparedStatement s2 = con.prepareStatement( selectSqlQuery ) ;
) { … Set parameters of PreparedStatements, etc. s1.executeUpdate() ; // Second try-with-resources, nested within first.
try (
ResultSet rs = s2.executeQuery() ;
) {
… process ResultSet
} catch ( SQLException e2 ) {
… handle exception related to ResultSet.
} } catch ( SQLException e ) {
… handle exception related to Connection or PreparedStatements.
}
}

Use try-with-resources的更多相关文章

  1. Xamarin+Prism开发详解二:Xaml文件如何简单绑定Resources资源文件内容

    我们知道在UWP里面有Resources文件xxx.resx,在Android里面有String.Xml文件等.那跨平台如何统一这些类别不一的资源文件以及Xaml设计文件如何绑定这些资源?应用支持多国 ...

  2. [免费了] SailingEase .NET Resources Tool (.NET 多语言资源编辑器)

    这是我2010年左右,写 Winform IDE (http://www.cnblogs.com/sheng_chao/p/4387249.html)项目时延伸出的一个小项目. 最初是以共享软件的形式 ...

  3. [Android]使用自定义JUnit Rules、annotations和Resources进行单元测试(翻译)

    以下内容为原创,欢迎转载,转载请注明 来自天天博客:http://www.cnblogs.com/tiantianbyconan/p/5795091.html 使用自定义JUnit Rules.ann ...

  4. [Erlang 0122] Erlang Resources 2014年1月~6月资讯合集

    虽然忙,有些事还是要抽时间做; Erlang Resources 小站 2014年1月~6月资讯合集,方便检索.      小站地址: http://site.douban.com/204209/   ...

  5. [Erlang 0114] Erlang Resources 小站 2013年7月~12月资讯合集

    Erlang Resources 小站 2013年7月~12月资讯合集,方便检索.     附 2013上半年盘点: Erlang Resources 小站 2013年1月~6月资讯合集    小站地 ...

  6. sqoop:Failed to download file from http://hdp01:8080/resources//oracle-jdbc-driver.jar due to HTTP error: HTTP Error 404: Not Found

    环境:ambari2.3,centos7,sqoop1.4.6 问题描述:通过ambari安装了sqoop,又添加了oracle驱动配置,如下: 保存配置后,重启sqoop报错:http://hdp0 ...

  7. Resources.Load加载文件返回null的原因

    1.文件夹都要放在Resources目录下 2.加载时photoName不需要扩展名 Texture2D t = Resources.Load<Texture2D>("Loadi ...

  8. 严重: Error starting static Resources java.lang.IllegalArgumentException:

    严重: Error starting static Resources java.lang.IllegalArgumentException: Document base E:\myworkspace ...

  9. (转载)android:android.content.res.Resources$NotFoundException: String resource ID #..

    android.content.res.Resources$NotFoundException: String resource ID #0x0 找不到资源文件ID #0x0 原因分析如下: 遇到这种 ...

  10. Sentiment Analysis resources

    Wikipedia: Sentiment analysis (also known as opinion mining) refers to the use of natural language p ...

随机推荐

  1. Spring项目使用Junit4测试配置

    我们经常要写junit测试,在不启动整个web项目的情况下,测试自己的service实现或者是dao实现,我们来充分利用下junit4的强大功能. 1.junit4的测试类 import java.u ...

  2. 平衡树Treap

    #include<iostream> #include<cstdio> #include<cstdlib> #include<algorithm> us ...

  3. LabView ModBus安装

    好久没写东西了(好菜哦...) 最近搞一个项目,开始入门LabVIEW,感觉类似于MATLAB里面的simulink 我使用LabVIEW是想用来和PLC通信的.因为PLC里面可以做ModBus,所以 ...

  4. python函数的闭包

    ---恢复内容开始--- python允许有内部函数,也就是说可以在函数内部再定义一个函数,这就会产生变量的访问问题,类似与java的内部类,在java里内部类可以直接访问外部类的成员变量和方法,不管 ...

  5. 【作业3.0】HansBug的第三次博客规格总结

    转眼间第三次作业了,似乎需要说点啥,那就说点. 规格&工业 说到这个,不得不提一下软件开发的发展史. 历史的进程 早在上世纪50年代,就已经有早期的编程语言出现,也开始有一些程序编写者出现(多 ...

  6. CSS字体渐变 & 隐藏浏览器滚动条 & grid布局(转载)

    字体渐变  https://www.zhangxinxu.com/study/201104/css3-text-gradient-2.html 隐藏浏览器滚动条  https://blog.csdn. ...

  7. 如何安装zsh,终极shell

    1,教程 教程 上知乎直接搜索终极shell也可以,话不多说,直接自己看教程吧 2,总之就是 sudo apt-get install zsh chsh ...修改设置 wget下载oh-my-zsh ...

  8. 软件测试之实际工作工作方式001--log4

    软件测试之实际工作工作方式001--log4 Dotest软件测试-董浩整理   领导安排任务后:   1)首先要确认理解:是指的某工作吗?具体有什么要求吗?时间截止到什么时候? 解析:   a.万一 ...

  9. nginx允许IP访问不生效问题【原创】

    使用nginx的nginx_upstream_check模块来检测后端服务器的转态时,设置只允许某段IP访问,发现不生效,不在此网段的IP也可以访问. 原因为在允许IP访问最后一定要加deny all ...

  10. 安装 python pip Django

    python 安装 1. 官网下载:以 window 为例,按提示下载,版本号根据实际需求选择: 2. 选择路径,安装完成后,命令行输入 python 检测是否安装成功,下图为安装成功显示:quit( ...