Advertisement
HarrJ

B8 Day 23 Connection!!!

Oct 6th, 2022
895
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.98 KB | None | 0 0
  1. package mattroseb8wk4;
  2. import java.sql.*;
  3. // KUNIN YUNG CONNECTOR SA GOOGLE CLASSROOM, I add sa library sa project properties
  4.  
  5. public class Day23Connect {
  6. //****************************************************
  7.     String address = "jdbc:mysql://localhost:3306/mr_batch8_db";// BAGUHIN YUNG DATABASE NAME
  8. //****************************************************
  9.     String userName = "root";
  10.     String passWord = "";
  11.     // kaya nasa labas yang tatlo ay para kung maraming
  12.     // method pwede gamitin ng paulit ulit
  13.     public static void main(String[] args) {
  14.         Day23Connect callMe = new Day23Connect();
  15.         callMe.connectionTest();
  16.     }
  17.    
  18.     public void connectionTest() {
  19.         try {
  20.             Connection conn = DriverManager.getConnection(
  21.                     address, userName, passWord);
  22.             System.out.println("testing");
  23.            
  24.             conn.close();
  25.         } catch (Exception e) {
  26.             System.out.println(e);
  27.         }
  28.     }
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement