Last active
December 17, 2015 19:19
-
-
Save ruseel/5659843 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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