- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathConnection.java
More file actions
Latest commit
31 lines (23 loc) · 734 Bytes
/
Copy pathConnection.java
File metadata and controls
31 lines (23 loc) · 734 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
27
28
29
30
31
packagedatabase;
importjava.sql.DriverManager;
publicclassConnection {
publicstaticvoidmain (String[] args) throwsException
{
database();
}
publicstaticConnectiondatabase(){
try{
Stringdriver = "com.mysql.jdbc.Driver";
Stringurl = "jdbc:mysql://localhost:3306/database";
Stringusername = "PNT";
Stringpassword = "Mdenam@786";
Class.forName(driver);
Connectioncon = (Connection) DriverManager.getConnection(url, username, password);
System.out.println("connected");
returncon;
} catch (Exceptione){
System.out.println(e);
}
returnnull;
}
}