Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package library;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- public class ConnectDBlibrary {
- private Connection conn;
- private String url;
- private String user;
- private String pass;
- private String db;
- public ConnectDBlibrary(){
- this.db="bnews";
- this.url="jdbc:mysql://localhost:3306/"+db+"?useUnicode=true&characterEncoding=UTF-8";
- this.user="root";
- this.pass="";
- }
- public Connection getConnectMysql() {
- //nap driver , java<8.0
- try{
- Class.forName("com.mysql.jdbc.Driver");
- conn=DriverManager.getConnection(url, user, pass);
- }
- catch(ClassNotFoundException | SQLException e){
- e.printStackTrace();
- }
- return conn;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement