Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- public class MySQL {
- public static final String USERNAME = "user-root";
- public static final String PASSWORD = "password=";
- public static final String DB_URL = "jdbc:mysql://localhost:3306/person1?";
- public MySQL(){
- try {
- Class.forName("com.mysql.jdbc.Driver");
- } catch (ClassNotFoundException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- public Connection getCon() {
- Connection con = null;
- try {
- con = DriverManager.getConnection(DB_URL+USERNAME+"&"+PASSWORD);
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return con;
- }
- }
Add Comment
Please, Sign In to add comment