-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathData.java
More file actions
31 lines (25 loc) · 772 Bytes
/
Data.java
File metadata and controls
31 lines (25 loc) · 772 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
package AIM;
import java.sql.*;
public class Data {
public ResultSet JDBC(String query, String database_name, String password) {
Connection c = null;
try {
c = DriverManager.getConnection("jdbc:mysql://localhost:3306/" + database_name + "", "root", password);
} catch (SQLException e) {
throw new RuntimeException(e);
}
Statement s = null;
try {
s = c.createStatement();
} catch (SQLException e) {
throw new RuntimeException(e);
}
ResultSet r;
try {
r = s.executeQuery(query);
} catch (SQLException e) {
throw new RuntimeException(e);
}
return r;
}
}