Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.*;
- public class CheckDatabaseConnection {
- private static final String DATABASE = "silvestri";
- private static final String USERNAME = "readonly";
- private static final String PASSWORD = "readonly";
- static String driver = "com.mysql.jdbc.Driver";
- static String url = "jdbc:mysql://cs.stcc.edu/" + DATABASE +
- "?user=" + USERNAME + "&password=" + PASSWORD;
- public static void main(String[] args) {
- try {
- Class.forName(driver).newInstance();
- System.out.println("Loaded driver");
- Connection conn = DriverManager.getConnection(url);
- System.out.println("Connected to database");
- conn.close();
- System.out.println("Closed connection");
- }
- catch (Exception e) {
- System.err.println(e.getMessage());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement