2019-09-20 15:02:17 +02:00
|
|
|
package db;
|
|
|
|
|
|
|
|
import javax.swing.table.DefaultTableModel;
|
|
|
|
import java.sql.Connection;
|
|
|
|
import java.sql.PreparedStatement;
|
|
|
|
import java.sql.ResultSet;
|
|
|
|
import java.sql.SQLException;
|
|
|
|
|
|
|
|
public class jdcb {
|
2019-09-27 10:58:13 +02:00
|
|
|
String username;
|
|
|
|
String password;
|
|
|
|
String dbName;
|
|
|
|
|
|
|
|
public jdcb(String username, String password, String dbName) {
|
|
|
|
this.username = username;
|
|
|
|
this.password=password;
|
|
|
|
this.dbName = dbName;
|
|
|
|
}
|
|
|
|
|
|
|
|
public ResultSet executeQuery(String sql) {
|
2019-09-20 15:02:17 +02:00
|
|
|
Database db = new MySQLConnector(
|
2019-09-27 10:58:13 +02:00
|
|
|
username,
|
|
|
|
password,
|
|
|
|
"192.168.65.15",
|
2019-09-20 15:02:17 +02:00
|
|
|
3306,
|
2019-09-27 10:58:13 +02:00
|
|
|
dbName);
|
2019-09-20 15:02:17 +02:00
|
|
|
|
|
|
|
Connection c = db.getConnection();
|
|
|
|
try {
|
|
|
|
PreparedStatement stmt =
|
|
|
|
c.prepareStatement(sql);
|
|
|
|
|
2019-09-27 10:58:13 +02:00
|
|
|
return stmt.executeQuery();
|
2019-09-20 15:02:17 +02:00
|
|
|
} catch (SQLException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
2019-09-27 10:58:13 +02:00
|
|
|
return null;
|
2019-09-20 15:02:17 +02:00
|
|
|
}
|
|
|
|
}
|