Advertisement
joseleonweb

Untitled

May 12th, 2021
793
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.53 KB | None | 0 0
  1. import java.sql.Connection;
  2. import java.sql.SQLException;
  3.  
  4. public class Main {
  5.  
  6.     public static void main(String[] args) {
  7.         // create a new connection from MySQLJDBCUtil
  8.         try (Connection conn = MySQLJDBCUtil.getConnection()) {
  9.            
  10.             // print out a message
  11.             System.out.println(String.format("Connected to database %s "
  12.                     + "successfully.", conn.getCatalog()));
  13.         } catch (SQLException ex) {
  14.             System.out.println(ex.getMessage());
  15.         }
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement