-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconnection.java
More file actions
37 lines (33 loc) · 1.01 KB
/
Copy pathconnection.java
File metadata and controls
37 lines (33 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package project;
import java.sql.*;
import java.awt.*;
import javax.swing.*;
/**
*
* @author akkii
*/
public class connection {
Connection con=null;
public static Connection connector()throws SQLException{
try{
Class.forName("com.mysql.jdbc.Driver");
System.out.println("driverloaded");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/db","root","akkii");
//JOptionPane.showMessageDialog(null,"connection succesfull");
return(con);
}
catch(ClassNotFoundException e){
System.out.println("exception="+e.getMessage());
return(null);
}
catch(SQLException e){
System.out.println("Sql="+e.getMessage());
return null;
}
}
}