日期:2014-05-18  浏览次数:20954 次

JSP+JavaBean+SQL Server,用户登陆,密码错误
JSP+JavaBean+SQL   Server,用户登陆,密码错误,这个问题捆饶我很久了,QQ:82689774,高手请赐教!急!!急!排除了密码中含有空格的可能!
连接SQL数据库,sqlBean.java
package   hou;

import   java.sql.*;
public   class   sqlBean{
String   sDBDriver   =   "com.microsoft.jdbc.sqlserver.SQLServerDriver ";
String     url= "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=educationi ";        

String     user= "sa ";        
String     password= "1 ";    
Connection     conn=     null;  
Statement   stmt   =   null;
ResultSet   rs   =   null;
public   sqlBean()
{
try
{Class.forName(sDBDriver);
}
catch(java.lang.ClassNotFoundException   e)
{
System.err.println( "sqlBean():   "   +   e.getMessage());
}
}

/////////////////插入操作
public   void   executeInsert(String   sql)  
{
try
{
conn   =   DriverManager.getConnection(url,user,password);
stmt   =   conn.createStatement();
stmt.executeUpdate(sql);
stmt.close();
conn.close();
}
catch(SQLException   ex)
{System.err.println( "sqlBean.executeUpdate: "+ex.getMessage());
}
}

//////////////////////查询操作
public   ResultSet   executeQuery(String   sql)
{
try
{
conn   =   DriverManager.getConnection(url,user,password);
stmt   =   conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
        rs   =   stmt.executeQuery(sql);
}
catch(SQLException   ex)
{
System.err.println( "sqlBean.executeQuery: "+ex.getMessage());
}
return   rs;
}

/////////////////////////更新操作
public   void   executeUpdate(String   sql)
{
        try   {
conn   =   DriverManager.getConnection(url,user,password);
stmt   =   conn.createStatement();
        stmt.executeUpdate(sql);
stmt.close();
        conn.close();
        }  
        catch(SQLException   ex)   {  
            System.err.println( "sqlBean.executeQuery:   "   +   ex.getMessage());
        }
}

//执行删除操作
public   void   executeDelete(String   sql)  
{
try
{conn   =   DriverManager.getConnection(url,user,password);
stmt   =   conn.createStatement();
stmt.executeUpdate(sql);
stmt.close();
        conn.close();
}  
catch(SQLException   ex)  
{
System.err.println( "sqlBean.executeDelete: "+ex.getMessage());
}
}

//关闭操作
public   void   closeStmt(){
        try{
            stmt.close();
          }