Afzzal87

Konesi.java

Jul 6th, 2018
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.85 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package koneksi;
  7. /**
  8.  *
  9.  * @author EZHAKOVA1687
  10.  */
  11.  
  12. import java.sql.Connection;
  13. import java.sql.DriverManager;
  14. import java.sql.Statement;
  15.  
  16. public class Koneksi {
  17. public static Connection con;
  18. public static Statement stm;
  19. public static void main(String args[]){
  20.     try {
  21.     String url ="jdbc:mysql://localhost/Test_connect";
  22.     String user="root";
  23.     String pass="";
  24.     Class.forName("com.mysql.jdbc.Driver");
  25.     con =DriverManager.getConnection(url,user,pass);
  26.     stm = con.createStatement();
  27.     System.out.println("You Are Conected;");
  28.     }  
  29.         catch (Exception e) {
  30.     System.err.println("Conecting failed"
  31.                 + "" +e.getMessage());
  32.     }
  33.     }
  34.     }
Add Comment
Please, Sign In to add comment