当前位置: 技术问答>java相关
关于javaBean的问题,高分请教~~
来源: 互联网 发布时间:2017-04-01
本文导语: conn.class如下 import java.sql.*; public class conn{ Connection conn=null; Statement stmt; ResultSet rs=null; String sConnStr=** //这里隐藏了,并且这里没有问题的~!!! public conn(){ try{ conn=DriverManager.getConnection(sConnStr); stmt=conn.cre...
conn.class如下
import java.sql.*;
public class conn{
Connection conn=null;
Statement stmt;
ResultSet rs=null;
String sConnStr=** //这里隐藏了,并且这里没有问题的~!!!
public conn(){
try{
conn=DriverManager.getConnection(sConnStr);
stmt=conn.createStatement();
}catch(SQLException e){
System.err.println("错误连接:"+e.getMessage());
}
}
public ResultSet executeQuery(String sql) {
rs=null;
try {
conn=DriverManager.getConnection(sConnStr);
stmt=conn.createStatement();
rs=stmt.executeQuery(sql);
}
catch(SQLException ex) {
System.err.println("aq.executeQuery: " + ex.getMessage());
System.err.println("aq.executeQuerystrSQL: " + sql);
}
return rs;
}
public void executeUpdate(String sql) {
try {
conn=DriverManager.getConnection(sConnStr);
stmt=conn.createStatement();
stmt.executeUpdate(sql);
}
catch(SQLException ex) {
System.err.println("aq.executeUpdate: " + ex.getMessage());
System.err.println("aq.executeUpadatestrSQL: " + sql);
}
}
}
jsp文件如下~~
intPageCount) intPage = intPageCount;
strSQL = "select * from book order by id desc";
sqlRst = strconn.executeQuery(strSQL);
strPage=request.getParameter("page");
if(strPage!=null){
intPage=Integer.parseInt(strPage);
if(intPage>intPageCount)
{
intPage=intPageCount;
}
else if(intPage
import java.sql.*;
public class conn{
Connection conn=null;
Statement stmt;
ResultSet rs=null;
String sConnStr=** //这里隐藏了,并且这里没有问题的~!!!
public conn(){
try{
conn=DriverManager.getConnection(sConnStr);
stmt=conn.createStatement();
}catch(SQLException e){
System.err.println("错误连接:"+e.getMessage());
}
}
public ResultSet executeQuery(String sql) {
rs=null;
try {
conn=DriverManager.getConnection(sConnStr);
stmt=conn.createStatement();
rs=stmt.executeQuery(sql);
}
catch(SQLException ex) {
System.err.println("aq.executeQuery: " + ex.getMessage());
System.err.println("aq.executeQuerystrSQL: " + sql);
}
return rs;
}
public void executeUpdate(String sql) {
try {
conn=DriverManager.getConnection(sConnStr);
stmt=conn.createStatement();
stmt.executeUpdate(sql);
}
catch(SQLException ex) {
System.err.println("aq.executeUpdate: " + ex.getMessage());
System.err.println("aq.executeUpadatestrSQL: " + sql);
}
}
}
jsp文件如下~~
intPageCount) intPage = intPageCount;
strSQL = "select * from book order by id desc";
sqlRst = strconn.executeQuery(strSQL);
strPage=request.getParameter("page");
if(strPage!=null){
intPage=Integer.parseInt(strPage);
if(intPage>intPageCount)
{
intPage=intPageCount;
}
else if(intPage