I am trying to develop
a relational database application. To do this I
will have to create multiple tables.At the
moment I am able to connect to a database called
COFFEEBREAK and create a table called COFFEES. I have
attempted to create a second table in the same database
called COFFEES2. The code compiles and runs but it only
creates the first table. Can anyone tell or show
me how to fix the code as without this I cannot
continue with my application.(Source code is given
below)Thanks everyoneimport java.sql.*;public
class connectiontest { public static void main(
String args[] ) { //Loads JDBC & ODBC
drivers and connects to given database
Connection connection; Statement
statement; String url = System.getProperty("user.dir") +
"\\COFFEEBREAK.mdb"; String conStr = "jdbc:odbc:Driver={Microsoft Access
Driver (*.mdb)};DBQ=" +
url; try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
connection =
DriverManager.getConnection(conStr);
connection.createStatement(); System.out.println("Connection
Established"); //If connection established
user should see this to inform them
//CREATE 2 TABLES, COFFEES & COFFEES2
try{ String createString; createString = "create
table COFFEES " + "(COF_NAME VARCHAR(32), " +
"SUP_ID INTEGER, " + "PRICE FLOAT, " + "SALES
INTEGER, " + "TOTAL INTEGER)"; String
createString2; createString2 = "create table COFFEES2"+
"(COFFEE_NAME2 VARCHAR (32), "+ "Make," +
"flavour)"; Statement sql =
connection.createStatement(); sql.executeUpdate(createString);
sql.executeUpdate(createString2); } catch(SQLException e){ //If
table exists
continue //insert some values to it String
insertQuery; } } catch (Exception
ex){ System.out.println("Connection Exception: " +
ex); System.out.println("Connection Exception: " + ex); }
}}