odbc&java Jdbc_Odbc桥连接的问题

samsam32 2004-05-08 02:53:08
Jdbc_Odbc桥连接的问题

用桥的时候一个连接总是只能供一对stmt和rs使用
如果我走JDBC的直连又可以只用一个连接

下面例一就会出错
下面例二就不会出错
我只想用ODBC的一个数据库连接
请教各位专家高手有什么好的解决办法,万分感谢

例一:
...............
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
Connection con = DriverManager.getConnection("jdbc:odbc:test", "user", "pwd");

Statement stmt1 = con.createStatement();
ResultSet rs1 = null;

Statement stmt2 = con.createStatement();
ResultSet rs2 = null;

rs1 = stmt1.executeQuery("select * from table1");
rs2 = stmt2.executeQuery("select * from table2");
.......................

例二:
.......................
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();

Connection con1 = DriverManager.getConnection("jdbc:odbc:test", "user", "pwd");
Statement stmt1 = con1.createStatement();
ResultSet rs1 = null;

Connection con2 = DriverManager.getConnection("jdbc:odbc:test", "user", "pwd");
Statement stmt2 = con2.createStatement();
ResultSet rs2 = null;

rs1 = stmt1.executeQuery("select * from table1");
rs2 = stmt2.executeQuery("select * from table2");
.......................
...全文
11 1 点赞 打赏 收藏 举报
写回复
1 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
netcoder 2004-05-08
这样行吗?
...............
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
Connection con = DriverManager.getConnection("jdbc:odbc:test", "user", "pwd");

Statement stmt1 = con.createStatement();
ResultSet rs1 = null;
ResultSet rs2 = null;

rs1 = stmt1.executeQuery("select * from table1");
rs2 = stmt1.executeQuery("select * from table2");
  • 打赏
  • 举报
回复
相关推荐
发帖
MS-SQL Server
加入

3.3w+

社区成员

MS-SQL Server相关内容讨论专区
申请成为版主
帖子事件
创建了帖子
2004-05-08 02:53
社区公告
暂无公告