DataBase.java~5~
上传用户:tanyanyong
上传日期:2013-06-23
资源大小:1355k
文件大小:1k
- package bookshop.util;
- /**
- * <p>数据专用包 </p>
- * <p>负责数据库的连接,数据的插入更新和删除 </p>
- * <p>Copyright: wxy Copyright (c) 2004</p>
- * <p>Company:juanjuan book shop online </p>
- * @by :wxy
- * @version 1.0
- */
- import java.sql.*;
- public class DataBase {
- public Connection conn;
- public Statement stmt;
- public ResultSet rs;
- public String sqlStr="";
- public DataBase() {
- }
- public boolean connect(){
- try{
- Class.forName("org.gjt.mm.mysql.Driver").newInstance();
- String url ="jdbc:mysql://localhost/BookStore?user=wxy&useUnicode=true&characterEncoding=8859_1";
- conn=DriverManager.getConnection(url);
- stmt = conn.createStatement ();
- }catch(Exception ee){
- System.out.println("connect db error:"+ee.getMessage());
- return false;
- }
- return true;
- }
- }