-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDatabaseConnection.java
More file actions
41 lines (30 loc) · 1.23 KB
/
DatabaseConnection.java
File metadata and controls
41 lines (30 loc) · 1.23 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
38
39
40
41
package oopprojecthalilkayra;
import java.sql.*;
import java.util.logging.Level;
import java.util.logging.Logger;
public class DatabaseConnection {
// database informations. only for this class
final private static int port = 3306;
final private static String host = "mysql-dbdeneme.alwaysdata.net";
final private static String dbUser = "dbdeneme";
final private static String dbPassword = "123456Mm..";
final private static String dbName = "dbdeneme_2025";
final private static String dburl = "jdbc:mysql://"+host+":"+port+"/"+dbName;
private Connection cn = null;
public Connection getConnection(){
try {
setCn(DriverManager.getConnection(dburl, dbUser, dbPassword));
System.out.println("\nYou're connecting to the online server please wait...");
} catch (SQLException ex) {
Logger.getLogger(Database.class.getName()).log(Level.SEVERE, null, ex);
System.out.println("\nServer Connection Failed");
}
return getCn();
}
public Connection getCn() {
return cn;
}
public void setCn(Connection cn) {
this.cn = cn;
}
}