|
我的bean
package db;
import java.sql.*;
import java.io.*;
import java.util.*;
public class dbConn{
String sDBDriver="com.microsoft.jdbc.sqlserver.SQLServerDriver";
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=disc";
String user="sa";
String password="20263588";
Statement stmt=null;
Connection conn=null;
ResultSet rs=null;
public dbConn(){
try{
Class.forName(sDBDriver).newInstance();
System.out.println("加载数据库驱动成功");
}
catch(Exception e)
{
e.printStackTrace() ;
}
}
public ResultSet executeQuery(String sql){
try{
conn=DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
System.out.print("连接数据库成功");
rs=stmt.executeQuery(sql);
}
catch(SQLException ex){
System.err.println(ex.getMessage());
}
return rs;
}
public void executeUpdate(String sql){
stmt=null;
rs=null;
try{
conn=DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
stmt.executeQuery(sql);
stmt.close();
conn.close();
}
catch(SQLException ex){
System.err.println(ex.getMessage());
}
}
public void closeStmt()
{
try{
stmt.close();
}
catch(SQLException e)
{
e.printStackTrace();
}
}
public void closeConn()
{
try{
conn.close();
}
catch(SQLException e)
{
e.printStackTrace();
}
}
}
login_confirm.jsp代码
登录验证
window.location="index_OK.jsp?mark=dfsd"
问题补充:sos提交表单部分
用户名
密 码
新会员注册
修改 |
|
|