package ywfx;/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2006</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/import java.sql.*;
public class Connect1 {
String sDBDriver = "com.informix.jdbc.IfxDriver";
String url = "jdbc:informix-sqli://192.168.1.100:8888/ywfx:INFORMIXSERVER=ywfx_tcp;user=ywfx;password=ywfx";
Connection conn = null;
ResultSet rs = null;
public Connect1() {
try {
Class.forName(sDBDriver);
}
catch (java.lang.ClassNotFoundException e) {
System.err.println("Connect1():" + e.getMessage());
}
} public ResultSet executeQuery(String sql) {
rs = null;
try {
conn = DriverManager.getConnection(url);
Statement stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
}
catch (SQLException ex) {
System.err.println("co.executeQuery:" + ex.getMessage());
}
return rs;
} public ResultSet branch() {
String sql="select branch_no,branch_name from branch";
try{
conn = DriverManager.getConnection(url);
PreparedStatement ps = conn.prepareStatement(sql);
ResultSet res = ps.executeQuery();
return res;
}
catch(Exception e){
return null;
}
}
}请问如何在jsp网页中获取return res的返回值。
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2006</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/import java.sql.*;
public class Connect1 {
String sDBDriver = "com.informix.jdbc.IfxDriver";
String url = "jdbc:informix-sqli://192.168.1.100:8888/ywfx:INFORMIXSERVER=ywfx_tcp;user=ywfx;password=ywfx";
Connection conn = null;
ResultSet rs = null;
public Connect1() {
try {
Class.forName(sDBDriver);
}
catch (java.lang.ClassNotFoundException e) {
System.err.println("Connect1():" + e.getMessage());
}
} public ResultSet executeQuery(String sql) {
rs = null;
try {
conn = DriverManager.getConnection(url);
Statement stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
}
catch (SQLException ex) {
System.err.println("co.executeQuery:" + ex.getMessage());
}
return rs;
} public ResultSet branch() {
String sql="select branch_no,branch_name from branch";
try{
conn = DriverManager.getConnection(url);
PreparedStatement ps = conn.prepareStatement(sql);
ResultSet res = ps.executeQuery();
return res;
}
catch(Exception e){
return null;
}
}
}请问如何在jsp网页中获取return res的返回值。
解决方案 »
- 急急急,劳烦各位大虾帮下忙,关于如何在子类中访问父类中的私有属性!
- 怎么匹配这个字符串*******************Contig 1 ********************?
- 一个想了三天零四个小时的笔试题
- 有个问题到现在好象还不见JAVA能做到-VPN
- java.lang.IllegalThreadStateException错误!
- 求助
- 请帮忙查错.在线等
- 有两个窗体frame1,frame2,我想在frame1 中显示frame2,因为frame1中有些数据要从frame2中得到,所以,在frame2返回之前,frame1中的程序好
- 各位大哥,请帮个忙!!!
- file类中有这种方法吗?
- 求基于java语言的节气计算方法
- 这样的代码会造成内存泄露吗?
完了调用executeQuery();
对返回结果做一定处理;
最后request.setAttribute("Result",res);
大概就这么个过程!
String sql="select branch_no,branch_name from branch";
try{
conn = DriverManager.getConnection(url);
PreparedStatement ps = conn.prepareStatement(sql);
ResultSet res = ps.executeQuery();
return res;
}
catch(Exception e){
return null;
}
}在jsp网页中直接用下面这种方也能接收呀?
ResultSet RS = workM.executeQuery(workM.branch());
while (RS.next()) {
String branch_no=RS.getString(1);
String branch_name=RS.getString(2);
}
}
RS.close();
ResultSet RS = workM.branch();
while (RS.next()) {
String branch_no=RS.getString(1);
String branch_name=RS.getString(2);
}
}
RS.close();
<%
ResultSet RS = workM.branch();
while (RS.next()) {
String branch_no=RS.getString(1);
Out.println(branch_no);
String branch_name=RS.getString(2);
Out.println(branch_name);
}
}
RS.close();
%>