use of org.apache.ddlutils.platform.CreationParameters in project siena by mandubian.
the class JdbcTest method createPersistenceManager.
@Override
public PersistenceManager createPersistenceManager(List<Class<?>> classes) throws Exception {
if (pm == null) {
Properties p = new Properties();
String driver = "com.mysql.jdbc.Driver";
String username = "siena";
String password = "siena";
String url = "jdbc:mysql://localhost/siena";
p.setProperty("driver", driver);
p.setProperty("user", username);
p.setProperty("password", password);
p.setProperty("url", url);
Class.forName(driver);
BasicDataSource dataSource = new BasicDataSource();
dataSource = new BasicDataSource();
dataSource.setUrl(url);
dataSource.setUsername(username);
dataSource.setPassword(password);
// 2 seconds max for wait a connection.
dataSource.setMaxWait(2000);
DdlGenerator generator = new DdlGenerator();
for (Class<?> clazz : classes) {
generator.addTable(clazz);
}
// get the Database model
Database database = generator.getDatabase();
Platform platform = PlatformFactory.createNewPlatformInstance("mysql");
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection connection = DriverManager.getConnection(url, username, password);
System.out.println(platform.getAlterTablesSql(connection, database));
// this will perform the database changes
CreationParameters cp = new CreationParameters();
// to search, it requires MyISAM
cp.addParameter(database.findTable("discoveries_search"), "ENGINE", "MyISAM");
cp.addParameter(database.findTable("discoveries_search2"), "ENGINE", "MyISAM");
platform.alterTables(connection, database, cp, true);
connection.close();
pm = new JdbcPersistenceManager();
pm.init(p);
}
return pm;
}
use of org.apache.ddlutils.platform.CreationParameters in project siena by mandubian.
the class JdbcTestNoAutoInc_4_SPECIALS method createPersistenceManager.
@Override
public PersistenceManager createPersistenceManager(List<Class<?>> classes) throws Exception {
if (pm == null) {
Properties p = new Properties();
String driver = "com.mysql.jdbc.Driver";
String username = "siena";
String password = "siena";
String url = "jdbc:mysql://localhost/siena";
p.setProperty("driver", driver);
p.setProperty("user", username);
p.setProperty("password", password);
p.setProperty("url", url);
Class.forName(driver);
BasicDataSource dataSource = new BasicDataSource();
dataSource = new BasicDataSource();
dataSource.setUrl(url);
dataSource.setUsername(username);
dataSource.setPassword(password);
// 2 seconds max for wait a connection.
dataSource.setMaxWait(2000);
DdlGenerator generator = new DdlGenerator();
for (Class<?> clazz : classes) {
generator.addTable(clazz);
}
// get the Database model
Database database = generator.getDatabase();
Platform platform = PlatformFactory.createNewPlatformInstance("mysql");
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection connection = DriverManager.getConnection(url, username, password);
System.out.println(platform.getAlterTablesSql(connection, database));
// this will perform the database changes
CreationParameters cp = new CreationParameters();
// to search, it requires MyISAM
cp.addParameter(database.findTable("discoveries_search"), "ENGINE", "MyISAM");
cp.addParameter(database.findTable("discoveries_search2"), "ENGINE", "MyISAM");
platform.alterTables(connection, database, cp, true);
connection.close();
pm = new JdbcPersistenceManager();
pm.init(p);
}
return pm;
}
Aggregations