资源简介
连接SQLServer必备的程序,打包好了的哦,直接调用,方便之极
代码片段和文件信息
//sql_data.java
package edu.hwadee.pro.bean;
import java.sql.*;
public class sql_data {
String sDBDriver = “com.microsoft.sqlserver.jdbc.SQLServerDriver“;
String url = “jdbc:sqlserver://localhost:1433;DatabaseName=test“;
String user = “sa“;
String password = “sa123“;
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
public sql_data() {
try {
Class.forName(sDBDriver);
} catch (java.lang.ClassNotFoundException e) {
System.err.println(“sql_data(): “ + e.getMessage());
}
}
public void executeInsert(String sql) {
try {// conn = DriverManager.getConnection(urluserpassword);
conn = DriverManager.getConnection(url user password);
stmt = conn.createStatement();
stmt.executeUpdate(sql);
stmt.close();
conn.close();
} catch (SQLException ex) {
System.err.println(“sql_data.executeUpdate:“ + ex.getMessage());
}
}
public ResultSet executeQuery(String sql) {
try {
conn = DriverManager.getConnection(url user password);
stmt = conn.createStatement(ResultSet.TYPE_SCRO
- 上一篇:list 转化成hashmap
- 下一篇:.apk
评论
共有 条评论