Advertisement
Guest User

Untitled

a guest
Mar 2nd, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.71 KB | None | 0 0
  1. import java.sql.*;
  2. // Basic DB Connection - The JDBC .jar file must be in your classpath
  3. // https://dev.mysql.com/doc/connector-j/5.1/en/connector-j-installing.html
  4. public class DBConn {
  5.     public static void main(String[] args) throws SQLException, ClassNotFoundException {
  6.         // Linux jdbc driver
  7.         Class.forName("org.mariadb.jdbc.Driver");
  8.         // In Windows
  9.         // Class.forName("com.mysql.jdbc.Driver");
  10.         System.out.println("Driver loaded");
  11.  
  12.         // Attempting connection
  13.         Connection conn = DriverManager.getConnection("jdbc:mysql://164.132.49.5", "mentcare", ""); // replace password
  14.  
  15.         System.out.println("Connected!");
  16.  
  17.         conn.close();
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement