· 6 years ago · Jul 09, 2019, 11:46 PM
1public static void CreateTable () throws SQLException
2{
3
4
5 try {
6 Connection con = DBConnection();
7 String statement = "CREATE TABLE IF NOT EXISTS tablename(id INT NOT NULL AUTO_INCREMENT, first VARCHAR(225), last VARCHAR(225) PRIMARY KEY(id)";
8 PreparedStatement create = con.prepareStatement(statement);
9 create.executeUpdate();
10 System.out.println("Table created...!");
11
12 } catch (Exception e) {
13 // TODO Auto-generated catch block
14 e.printStackTrace();
15 System.out.println("Could not create table...!");
16
17 }