使用JDBC驱动程序,我该如何使用来自不同查询多个结果集,而不会不断地打开和关闭连接,因为它站在IM提取w.e我需要的,它传递给另一种方法。每次打开多个结果,不同的查询,同一个数据库SQLSERVER
public static void OppQuery() {
Connection conn = null;
Statement stmt = null;
ResultSet result_set = null;
try {
Class.forName(JDBC_DRIVER);
conn = DriverManager.getConnection(DB_URL);
stmt = conn.createStatement();
String emailInfoQuery = "FROM WHERE";
}
public static void addQuery(String latestRenewalId) {
Connection conn = null;
Statement stmt = null;
ResultSet result_set = null;
try {
Class.forName(JDBC_DRIVER);
conn = DriverManager.getConnection(DB_URL);
stmt = conn.createStatement();
String new_AddressLine1, new_AddressLine2;
new_AddressLine1=new_AddressLine2="";
int new_ChannelOption= 0;
}
我试着在一个方法使用多个结果集,但它不停地抛出异常说结果集被关闭了一个新的康涅狄格州,Statement和ResultSet。我没有与SqlServver了丰富的经验,因此任何指导,将有助于:-)
你目前的代码没有你描述的问题(但它似乎也是不完整的) –
我想知道我可以避免这种情况,并结合成一种方法没有用一个连接分开全部 – Bgreen