package controller;
import com.mysql.jdbc.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
public class db {
static Connection c;
public static void createConnection() throws Exception {
Class.forName("com.mysql.jdbc.Driver");
c = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3307/dbname", "root", "password");
}
public static void iud(String s) throws Exception {
if (c == null) {
createConnection();
}
Statement stmt = c.createStatement();
stmt.executeUpdate(s);
}
public static ResultSet search(String s) throws Exception {
if (c == null) {
createConnection();
}
Statement stmt = c.createStatement();
ResultSet rs = stmt.executeQuery(s);
return rs;
}
}