Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Connection_maker
- {
- private Connection conn;
- private static final String DESTINATION = "jdbc:mysql://localhost/";
- public Connection_maker()
- {
- try
- {
- Class.forName("com.mysql.jdbc.Driver");
- this. conn = java.sql.DriverManager.getConnection(DESTINATION, "root", "");
- System.out.println("connected");
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- public static void main(String[] args)
- {
- new Connection_maker();
- }
- }
- bool isAlive(){
- try{
- String query = "SELECT 1";
- Statement st = this.conn.createStatement(ue);
- ResultSet rs = st.executeQuery(query);
- return true;
- }catch(SQLException e){
- // honestly kind of non-specific ??
- return false;
- }
- }
Add Comment
Please, Sign In to add comment