回 帖 发 新 帖 刷新版面

主题:2接上一个问题!!!!

2、这是servlet!!!!!!!!!!!!!!!!!!!!!!
package test;
import java.sql.*;
public class ConnSQLServer
{
String serverName="localhost";
String sDBDriver="com.microsoft.jdbc.sqlserver.SQLServerDriver";
String sConnStr="jdbc:microsoft:sqlserver://XF:1433;DatabaseName=qam";
Connection connect=null;
ResultSet rs=null;
public ConnSQLServer()
  {
try
{
  Class.forName(sDBDriver);
}
catch (java.lang.ClassNotFoundException e)
{
     System.err.println(e.getMessage());
}
   }
public ResultSet executeQuery(String sql)
  {
try
{
  connect=DriverManager.getConnection(sConnStr,"sa","xf");
    Statement stmt=connect.createStatement();
    rs=stmt.executeQuery(sql);
}
catch (SQLException ex)
   {
     System.err.println(ex.getMessage());
}
   return rs;
   }
public int executeUpdate(String sql)
  {
   int result=0;
  try
  {
    connect=DriverManager.getConnection(sConnStr,"sa","xf");
    Statement stmt=connect.createStatement();
    result=stmt.executeUpdate(sql);
  }
  catch (SQLException ex)
  {
     System.err.println(ex.getMessage());
  }
return result;

}
}

回复列表 (共2个回复)

沙发

出什么问题了,说明白了啊

板凳

这是servlet????????

我来回复

您尚未登录,请登录后再回复。点此登录或注册