Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
- static final String DB_URL = "jdbc:mysql://localhost:3306/SecureSharedStore";
- // Database credentials
- static final String USER = "root";
- static final String PASS = "password";
- public static void main(String[] args) {
- Connection conn = null;
- Statement stmt = null;
- try{
- //STEP 2: Register JDBC driver
- Class.forName("com.mysql.jdbc.Driver");
- //STEP 3: Open a connection
- System.out.println("Connecting to database...");
- conn = DriverManager.getConnection(DB_URL, USER, PASS);
- } catch(SQLException se){
- //Handle errors for JDBC
- se.printStackTrace();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement