DataBase.java~5~
资源名称:bookshop.zip [点击查看]
上传用户:sxlinghang
上传日期:2022-07-20
资源大小:1405k
文件大小:1k
源码类别:
数据库编程
开发平台:
Java
- 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;
- }
- }