Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/database_name..
- // JDBC driver name and database URL
- static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
- static final String DB_URL = "jdbc:mysql://localhost:3306/program1";
- // Database credentials
- static final String USER = "user";
- static final String PASS = "pass";
- private static Connection conn = null;
- /*
- * Create connection to the DB in singletone
- * */
- protected static Connection getConnection() throws ClassNotFoundException, SQLException
- {
- if(conn==null)
- {
- try
- {
- // Register JDBC driver
- //Class.forName(JDBC_DRIVER);
- // Open connection
- conn = DriverManager.getConnection(DB_URL,USER,PASS);
- }
- catch ( SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- if(conn != null)
- conn.close();
- }
- }
- return conn;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement