Skip to content

Instantly share code, notes, and snippets.

@ruseel
Last active December 17, 2015 19:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ruseel/5659843 to your computer and use it in GitHub Desktop.
Save ruseel/5659843 to your computer and use it in GitHub Desktop.
import java.sql.*;
public class ConnectionAlone {
@SuppressWarnings("unused")
public static void main(String[] args) throws SQLException {
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException e) {
}
try (Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/dbcon_test", "root", "")) {
try (Statement stm = con.createStatement()) {
stm.execute("DROP TABLE IF EXISTS A;");
boolean b = stm.execute("CREATE TABLE A (field_a TEXT not null);");
int nRow = stm.executeUpdate("INSERT INTO A(field_a) values ('a');");
ResultSet rs = stm.executeQuery("select * from A");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment