* place: nxu.edu.cn
* email:[email protected]
*/
package Test;
import Java.sql.*;
/**
* @author Administrator
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class conndb2005 {
String user="sa";
String passWord="123";
String sDBDriver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
String sConnStr = "jdbc:sqlserver://localhost:1433;DatabaseName=temp";
Connection conn = null;
ResultSet rs = null;
String param[];
public void setParam(String[] param)
{
this.param=param;
}
public conndb2005() {
try {
Class.forName(sDBDriver);
}
catch(Java.lang.ClassNotFoundException e) {
System.err.println("conndb2005(): " + e.getMessage());
}
}
public ResultSet executeQuery(String sql) {
rs = null;
try {
conn = DriverManager.getConnection(sConnStr,user,passWord);
Statement stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
}
catch(SQLException ex) {
System.err.println("aq.executeQuery: " + ex.getMessage());
}
return rs;
} //select
public void insertRecord(String sqlinsert) throws SQLException,Java.io.UnsupportedEncodingException
{
try
{
PreparedStatement insert_stm=conn.prepareStatement(sqlinsert);
if (param!=null)
for(int i