public static void runsql(String Q)
{
try
{
// create a mysql database connection
String myUrl = "jdbc:mysql://localhost:3306/firewall?zeroDateTimeBehavior=convertToNull";
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection(myUrl,"root", "password");
if (conn != null) {
System.out.println("Connected");
}
Statement st = conn.createStatement();
st.executeUpdate(Q);
conn.close();
}
catch (Exception e)
{
System.err.println("Got an exception!");
System.err.println(e.getMessage());
}
}
{
try
{
// create a mysql database connection
String myUrl = "jdbc:mysql://localhost:3306/firewall?zeroDateTimeBehavior=convertToNull";
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection(myUrl,"root", "password");
if (conn != null) {
System.out.println("Connected");
}
Statement st = conn.createStatement();
st.executeUpdate(Q);
conn.close();
}
catch (Exception e)
{
System.err.println("Got an exception!");
System.err.println(e.getMessage());
}
}
Comments
Post a Comment