在一个JSP页面中,要同时操作两个表或者更多的表(不是关联查询,表之间没有关系).该怎么办呢?有兴趣的进来看看
这只能操作一个表,如果我要同时查另一个表,或者同时查两到三个表(表之间无联系,是各自独立的),该怎么办?再建立个连接?再建stmt,rs??
请高手指教
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
String strcon="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=database";
String user="sa";
String password="sa";
Connection conn= DriverManager.getConnection(strcon,user,password);
Statement stmt=conn.createStatement();
String sql="select imc01,imc02 from imc_file ";
ResultSet rs=null;
stmt=conn.createStatementResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
rs = stmt.executeQuery(sql);
问题点数:20、回复次数:8Top
1 楼beautywolf110(☆→★)回复于 2004-12-02 18:47:11 得分 10
再建stmt,rsTop
2 楼jFresH_MaN(十一月的萧邦-夜曲)回复于 2004-12-02 18:47:17 得分 0
如果是同一个数据库就用一个连接就行了,查找地时候用全名database.table
如果设计多个数据库就要多个连接Top
3 楼wuweijie(无痕)回复于 2004-12-02 18:50:01 得分 0
能给个例子吗?我是新手.Top
4 楼wuweijie(无痕)回复于 2004-12-02 19:18:42 得分 0
这样子是不是要先关闭rs呢,我的意思是我要同时显示两个rs或者是三个rs的内容,而不是先关一个,再打开一个Top
5 楼bj_2008(阳光)回复于 2004-12-02 19:29:41 得分 10
很简单了。
一个Connection conn=getConnection()就行
然后分别建立
Statement stmt1=conn.createStatement();
Statement stmt2=conn.createStatement();
Statement stmt3=conn.createStatement();
conn.close()
Top
6 楼bj_2008(阳光)回复于 2004-12-03 13:45:46 得分 0
很简单了。
一个Connection conn=getConnection()
Statement stmt1=conn.createStatement();
就行
select Products.ProductName,Suppliers.CompanyName
from Products join Suppliers on Products.SupplierID=Suppliers.SupplierID
where Products.ProductName= 'Chai' or Products.ProductName='Chang'or Products.ProductName != 'null'
Top
7 楼bj_2008(阳光)回复于 2004-12-03 13:46:16 得分 0
很简单了。
一个Connection conn=getConnection()
Statement stmt1=conn.createStatement();
就行
select Products.ProductName,Suppliers.CompanyName
from Products join Suppliers on Products.SupplierID=Suppliers.SupplierID
Top
8 楼wuweijie(无痕)回复于 2004-12-04 16:33:42 得分 0
结贴 to bj_2008:说了不是关联查询,还是听不明白.....Top




