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

XP下用3个架包连接数据库不好用,在线静候
String   id=(String)request.getParameter( "id ");
String   sql   =   "select   *   from   login   where   id= ' "+id+ " ' ";
String   url=   "jdbc:microsoft:sqlserver://localhost:1433;databaseName=master ";
String   driver   =   "com.microsoft.jdbc.sqlserver.SQLServerDriver ";
String   username   =   "sa ";
String   userpass   =   "sa ";
ResultSet   rs;
try
{
        Class.forName(driver);
        Connection   con   =   DriverManager.getConnection(url,username,userpass);
        PreparedStatement   ps   =   con.prepareStatement(sql);
        rs=ps.executeQuery();
        if(rs.next())
{
out.print( "用户id: "+id);
                    out.print( "用户密码: "+rs.getString( "pwd "));
out.print( "用户姓名: "+rs.getString( "name "));
out.print( "姓别: "+rs.getString( "sex "));
out.print( "年龄: "+rs.getInt( "age "));

}
else
{
out.print( " <h2> 尚无此信息 </h2> ");

}
                rs.close();
                ps.close();
                con.close();
}

        catch(ClassNotFoundException   ce)
        {
        ce.printStackTrace();
                }
        catch(SQLException   se)
        {
        se.printStackTrace();
                }
        catch(Exception   e)
        {
        e.printStackTrace();
                }
               

------解决方案--------------------
第一,你的jdbc三个驱动包要放到你工程的lib包里,第二,你要打上sql的sp4补丁.这个补丁下载了要解压后再安装才行.
------解决方案--------------------
没升级吧
------解决方案--------------------
http://www.greendown.cn/soft/1954.html
http://www.yich.org/Soft/xitong/sjbd/200701/548.html
------解决方案--------------------
确定你的SQL2000安装了SP4或者SP3,不然链接不上
------解决方案--------------------
打一下sp4补丁