dbconnectionmanager.java

来自「图书管理系统毕业设计源代码,图书管理系统毕业设计源代码图书管理系统毕业设计源代码」· Java 代码 · 共 58 行

JAVA
58
字号
/* * DBConnectionManager.java * * Created on 2006年4月22日, 上午11:10 * * To change this template, choose Tools | Options and locate the template under * the Source Creation and Management node. Right-click the template and choose * Open. You can then make changes to the template in the Source Editor. */package mySql;import java.sql.*;/** * * @author wang */public class DBConnectionManager {    private String driverName="sun.jdbc.odbc.JdbcOdbcDriver";//数据库驱动名    private String url="jdbc:odbc:wySystem";//定义连接的数据库url    private String user="admin";    private String password="admin";    /** Creates a new instance of DBConnectionManager */    public void setDriverName(String newDriverName){  //设置驱动名        driverName=newDriverName;    }    public String getDriverName(){ //获取驱动名        return driverName;    }    public void setUrl(String newUrl){ //设置连接数据库的url        url=newUrl;    }    public String getUrl(){ //获取url        return url;    }    public void setUser(String newUser){        user=newUser;    }    public String getUser(){        return user;    }    public void setPassword(String newPassword){        password=newPassword;    }    public String getPassword(){        return password;    }    public Connection getConnection(){ //获取数据库连接        try{            Class.forName(driverName);//加载数据库驱动            return DriverManager.getConnection(url,user,password);        }        catch(Exception e){            e.printStackTrace();            return null;        }    }} 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?