Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // JDBC driver name and database URL
- final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
- final String DB_URL = "jdbc:mysql://127.0.0.1:3306/db";
- // Database credentials
- final String USER = "mapo";
- final String PASS = "mapo";
- Connection conn = null;
- Statement stmt = null;
- try {
- //STEP 2: Register JDBC driver
- Class.forName(JDBC_DRIVER);
- //STEP 3: Open a connection_
- System.out.println("Connecting to database...");
- conn = (Connection) DriverManager.getConnection(DB_URL,USER,PASS);
- } catch (SQLException | ClassNotFoundException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement