1、新建Java类MyDBase
package MyDB;import java.sql.*;public class MyDBase {Connection Conn;boolean Ecode = false;String ES;ResultSet RS;Statement sql;public MyDBase(String DBServer, String DBName, String DBUser, String DBPwd) {String driverName = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; // 加载JDBC驱动String dbURL = "jdbc:sqlserver://"+DBServer+";DatabaseName="+DBName; // 连接服务器和数据库try {Class.forName(driverName);Conn = DriverManager.getConnection(dbURL, DBUser, DBPwd);} catch (Exception e) {Ecode=true;ES=e.getMessage();}}public ResultSet DBResultSet(String SQL){try {sql=Conn.createStatement();return(sql.executeQuery(SQL));} catch (SQLException e) {Ecode=true;ES=e.getMessage();e.printStackTrace();return null;}}public String ErrM