SHOW:
|
|
- or go back to the newest paste.
1 | import java.sql.*; | |
2 | ||
3 | public class CheckDatabaseConnection { | |
4 | private static final String DATABASE = "silvestri"; | |
5 | private static final String USERNAME = "readonly"; | |
6 | private static final String PASSWORD = "readonly"; | |
7 | ||
8 | ||
9 | static String driver = "com.mysql.jdbc.Driver"; | |
10 | static String url = "jdbc:mysql://cs.stcc.edu/" + DATABASE + | |
11 | "?user=" + USERNAME + "&password=" + PASSWORD; | |
12 | ||
13 | public static void main(String[] args) { | |
14 | try { | |
15 | Class.forName(driver).newInstance(); | |
16 | System.out.println("Loaded driver"); | |
17 | try{ | |
18 | - | Connection conn = DriverManager.getConnection(url); |
18 | + | Connection conn = Drivermanager.getConnection(url,); |
19 | Connection conn = DriverManager.getConnection(url);} | |
20 | ||
21 | - | conn.close(); |
21 | + | |
22 | ||
23 | ||
24 | System.out.println("Closed connection"); | |
25 | } | |
26 | catch (Exception e) { | |
27 | System.err.println(e.getMessage()); | |
28 | - | } |
28 | + | |
29 | } | |
30 | }. } |