-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConn.java
More file actions
26 lines (22 loc) · 846 Bytes
/
Conn.java
File metadata and controls
26 lines (22 loc) · 846 Bytes
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
package com.crud.applaundry;
import javax.swing.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class Conn {
private static Connection connect;
public static Connection connect() throws SQLException {
try {
String DB = "jdbc:mysql://localhost/database_laundry";
String user = "root";
String pass = "";
DriverManager.registerDriver(new com.mysql.cj.jdbc.Driver());
connect = DriverManager.getConnection(DB, user, pass);
} catch (SQLException e) {
JOptionPane.showMessageDialog(null, "No Database Connection", "Error", JOptionPane.INFORMATION_MESSAGE);
System.err.println(e.getMessage());
System.exit(0);
}
return connect;
}
}