Java DataSource createTables(final DataSource ds)

Here you can find the source of createTables(final DataSource ds)

Description

Creates the tables in the database

License

Apache License

Parameter

Parameter Description
ds the DataSource to CREATE into

Declaration

public static void createTables(final DataSource ds) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import javax.sql.DataSource;

public class Main {
    /**//w w w  .j a  va2 s  .  com
     * Creates the tables in the database
     * @param ds the DataSource to CREATE into
     */
    public static void createTables(final DataSource ds) {
        try {
            final String stmt = "create table USERS(username varchar(50), email varchar(50), Primary Key (username));";
            ds.getConnection().prepareStatement(stmt).execute();
        } catch (Exception e) {
            // do nothing -- probably just called twice as part of a unit tests
        }
    }
}

Related

  1. createDerbyEmbeddedDataSource(Properties props)
  2. createTable(DataSource ds, String ddl)
  3. createTable(DataSource ds, String tableName)
  4. createTableRecommendation(DataSource dataSource)
  5. createTables(DataSource ds)
  6. doInsert(DataSource ds, String tableName, int id, String value)
  7. doSelect(DataSource ds, String tableName, int id)
  8. execute(DataSource ds, String sql, Object... args)
  9. execute(String execute, DataSource datasource)