package com.mao.dbc;
import java.sql.*;
public class DataBaseConnection {
final String dbdriver = "com.mysql.jdbc.Driver";
final String dburl = "jdbc:mysql://localhost:3306/test";
final String dbuser = "root";
final String dbpass = "3100949";
Connection conn = null;
public DataBaseConnection() {
try {
Class.forName(dbdriver);
conn = DriverManager.getConnection(dburl, dbuser, dbpass);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("数据库连接出错");
}
}
public Connection getConnection() {
return this.conn;
}
public void close() {
try {
this.conn.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
System.out.println("关闭连接");
}
}
}
posted on 2008-06-04 14:54
蓝山 阅读(140)
评论(0) 编辑 收藏