Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package pkgfinal;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- import javax.swing.JOptionPane;
- /**
- *
- * @author administrator
- */
- public final class DB {
- public static final String DB_URL = "jdbc:mysql://localhost:3306/jamdb";
- public static final String DB_USERNAME = "root";
- public static final String DB_PASSWORD = "";
- public static final Connection getConnection() {
- Connection conn = null;
- try {
- Class.forName("com.mysql.jdbc.Driver").newInstance();
- conn = (com.mysql.jdbc.Connection) DriverManager.getConnection(DB.DB_URL, DB.DB_USERNAME, DB.DB_PASSWORD);
- } catch (ClassNotFoundException | IllegalAccessException | InstantiationException | SQLException ex) {
- JOptionPane.showMessageDialog(null, ex.getMessage());
- }
- return conn;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement