Here you can find the source of createTable(Connection dbCon, String tableName, String fields)
public static void createTable(Connection dbCon, String tableName, String fields) throws Exception
//package com.java2s; // it under the terms of the GNU General Public License as published by import java.sql.Connection; import java.sql.DatabaseMetaData; import java.sql.ResultSet; import java.sql.Statement; public class Main { public static void createTable(Connection dbCon, String tableName, String fields) throws Exception { if (!testIfTableExist(dbCon, tableName)) { Statement aStmt = dbCon.createStatement(); String sql = "CREATE TABLE " + tableName + " " + fields; aStmt.execute(sql);/*from w w w . ja v a 2 s . c om*/ } } public static boolean testIfTableExist(Connection dbCon, String tableName) throws Exception { DatabaseMetaData meta = dbCon.getMetaData(); String[] types = { "TABLE" }; ResultSet aRs = meta.getTables(null, null, tableName, types); if (aRs.next()) return true; return false; } }