package util;
/*
* date: 2004-11-17
* author:zhangyu6050;
* todo: 一个数据库封装类,作用是:
* 获取数据库连接
* 通过接受的SQL语句选择数据库并且返回结果
* 期间要作出以下判定:1 假如sql用来查询:、、、、
* 2 假如sql用来update:、、、、
*
* bugs:
* 改进:实现接口:sqlQuery;
* 主要继续一些比如ERROR,SUCCESS等的常量!
*/
//package util;
import Java.util.List;
import java.sql.*;
public class mysql {
private String dirverName=Configs.dirverName;
private String URL=Configs.URL;
private String passWord=Configs.password;
private String userName=Configs.userName;
private Connection conn = null;
private Statement stmt = null;
private PreparedStatement prepstmt = null;
public Mysql(){
try {
getDataSource();
stmt=conn.createStatement();
} catch (SQLException e) {
System.out.print("conn.createStatement()发生错误!");
e.printStackTrace();
}
}
public Mysql(String query){
init(query);
}
protected void init(String aqurey){
try {
stmt=conn.createStatement();
prepareStatement(aqurey);
} catch (SQLException e) {
System.out.print("conn.createStatement()发生错误!");
e.printStackTrace();
}
}