主题: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;
}
}
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;
}
}