Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- public class Sample {
- private static final String USERNAME = "root";
- private static final String PASSWORD = "alan";
- private static final String CONN_STRING = "jdbc:mysql://localhost:3306/sample?useTimezone=true&serverTimezone=UTC";
- public static void main(String[] args) throws ClassNotFoundException{
- Connection conn = null;
- try {
- Class.forName("com.mysql.cj.jdbc.Driver");
- conn = DriverManager.getConnection(CONN_STRING, USERNAME, PASSWORD);
- System.out.println("Connected");
- } catch (SQLException e) {
- System.out.println("SQLException: " + e.getMessage());
- System.out.println("SQLState: " + e.getSQLState());
- System.out.println("VendorError: " + e.getErrorCode());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement