本文整理汇总了Java中org.apache.ddlutils.PlatformFactory.createNewPlatformInstance方法的典型用法代码示例。如果您正苦于以下问题:Java PlatformFactory.createNewPlatformInstance方法的具体用法?Java PlatformFactory.createNewPlatformInstance怎么用?Java PlatformFactory.createNewPlatformInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.ddlutils.PlatformFactory
的用法示例。
在下文中一共展示了PlatformFactory.createNewPlatformInstance方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createDatabaseObject
import org.apache.ddlutils.PlatformFactory; //导入方法依赖的package包/类
private Database createDatabaseObject(Module module) {
final Properties props = OBPropertiesProvider.getInstance().getOpenbravoProperties();
final BasicDataSource ds = new BasicDataSource();
ds.setDriverClassName(props.getProperty("bbdd.driver"));
if (props.getProperty("bbdd.rdbms").equals("POSTGRE")) {
ds.setUrl(props.getProperty("bbdd.url") + "/" + props.getProperty("bbdd.sid"));
} else {
ds.setUrl(props.getProperty("bbdd.url"));
}
ds.setUsername(props.getProperty("bbdd.user"));
ds.setPassword(props.getProperty("bbdd.password"));
Platform platform = PlatformFactory.createNewPlatformInstance(ds);
platform.getModelLoader().setOnlyLoadTableColumns(true);
if (module != null) {
final String dbPrefix = module.getModuleDBPrefixList().get(0).getName();
final ExcludeFilter filter = DBSMOBUtil.getInstance().getExcludeFilter(
new File(props.getProperty("source.path")));
filter.addPrefix(dbPrefix);
return platform.loadModelFromDatabase(filter, dbPrefix, true, module.getId());
}
return platform.loadModelFromDatabase(null);
}
示例2: createWord
import org.apache.ddlutils.PlatformFactory; //导入方法依赖的package包/类
public void createWord() {
DruidDataSource dataSource = new DruidDataSource();
dataSource.setDriverClassName("com.mysql.jdbc.Driver");
dataSource.setUrl("jdbc:mysql://localhost:3306/xiu?useUnicode=true&characterEncoding=UTF-8");
dataSource.setUsername("root");
dataSource.setPassword("");
Platform platform = PlatformFactory.createNewPlatformInstance(dataSource);
Database model = platform.readModelFromDatabase("xiu");
System.out.println(model.toVerboseString());
System.out.println(Boon.toPrettyJson(model));
org.apache.ddlutils.model.Table dbTable = model.findTable("t_user");
ForeignKey[] fks = dbTable.getForeignKeys();
for (ForeignKey fk : fks) {
System.out.println(fk.getName());
System.out.println(fk.getFirstReference().getLocalColumnName());
System.out.println(fk.getForeignTableName());
System.out.println(fk.getFirstReference().getForeignColumnName());
}
toWord(model);
}
示例3: initDB
import org.apache.ddlutils.PlatformFactory; //导入方法依赖的package包/类
private void initDB() {
try {
logger.debug("Initializing DB...");
Database db = new DatabaseIO().read(new InputStreamReader(JvmMonitorLoader.class.getResourceAsStream("/dbSchema.xml"), "UTF-8"));
Platform platform = PlatformFactory.createNewPlatformInstance(DerbyPlatform.DATABASENAME);
EmbeddedDataSource dataSource = new EmbeddedDataSource();
dataSource.setDatabaseName(databasePath + DB_NAME);
dataSource.setCreateDatabase("create");
platform.setDataSource(dataSource);
if (platform.readModelFromDatabase(DB_NAME).getTableCount() == 0) { //TODO is that needed?
platform.createTables(db, false, false);
} else {
platform.alterTables(db, false);
}
} catch (DdlUtilsException | UnsupportedEncodingException e) {
throw new IllegalStateException(e);
}
}
示例4: createNewDatabase
import org.apache.ddlutils.PlatformFactory; //导入方法依赖的package包/类
@Override
public boolean createNewDatabase(String xmlPath, String dbPath) {
try {
parseXML(xmlPath);
Platform platform = PlatformFactory.createNewPlatformInstance(DB_NAME);
platform.createDatabase(DRIVER, getDatabasePath(dbPath), database_username, database_password, getUserPasswordProperties());
establishDBConnection(dbPath);
createTables(DB_NAME);
} catch (Exception e) {
lastError = e;
return false;
}
return true;
}
示例5: createNewDatabasefromResourceXML
import org.apache.ddlutils.PlatformFactory; //导入方法依赖的package包/类
@Override
public boolean createNewDatabasefromResourceXML(String xmlResPath, String dbPath) {
try {
parseXMLfromResource(xmlResPath);
Platform platform = PlatformFactory.createNewPlatformInstance(DB_NAME);
platform.createDatabase(DRIVER, getDatabasePath(dbPath), database_username, database_password, getUserPasswordProperties());
establishDBConnection(dbPath);
createTables(DB_NAME);
} catch (Exception e) {
lastError = e;
return false;
}
return true;
}
示例6: getPlatform
import org.apache.ddlutils.PlatformFactory; //导入方法依赖的package包/类
/**
* Creates the platform for the configured database.
*
* @return The platform
*/
public Platform getPlatform() throws BuildException
{
if (_platform == null)
{
if (_databaseType == null)
{
if (_dataSource == null)
{
throw new BuildException("No database specified.");
}
if (_databaseType == null)
{
_databaseType = new PlatformUtils().determineDatabaseType(_dataSource.getDriverClassName(),
_dataSource.getUrl());
}
if (_databaseType == null)
{
_databaseType = new PlatformUtils().determineDatabaseType(_dataSource);
}
}
try
{
_platform = PlatformFactory.createNewPlatformInstance(_databaseType);
}
catch (Exception ex)
{
throw new BuildException("Database type "+_databaseType+" is not supported.", ex);
}
if (_platform == null)
{
throw new BuildException("Database type "+_databaseType+" is not supported.");
}
_platform.setDataSource(_dataSource);
_platform.setDelimitedIdentifierModeOn(isUseDelimitedSqlIdentifiers());
_platform.setForeignKeysSorted(isSortForeignKeys());
}
return _platform;
}
示例7: getPlatform
import org.apache.ddlutils.PlatformFactory; //导入方法依赖的package包/类
private Platform getPlatform() {
final Properties props = OBPropertiesProvider.getInstance().getOpenbravoProperties();
final BasicDataSource ds = new BasicDataSource();
ds.setDriverClassName(props.getProperty("bbdd.driver"));
if (props.getProperty("bbdd.rdbms").equals("POSTGRE")) {
ds.setUrl(props.getProperty("bbdd.url") + "/" + props.getProperty("bbdd.sid"));
} else {
ds.setUrl(props.getProperty("bbdd.url"));
}
ds.setUsername(props.getProperty("bbdd.user"));
ds.setPassword(props.getProperty("bbdd.password"));
return PlatformFactory.createNewPlatformInstance(ds);
}
示例8: getPlatform
import org.apache.ddlutils.PlatformFactory; //导入方法依赖的package包/类
/**
* Returns a dbsourcemanager Platform object
*
* @return A Platform object built following the configuration set in the Openbravo.properties
* file
*/
public Platform getPlatform() {
Properties obProp = OBPropertiesProvider.getInstance().getOpenbravoProperties();
// We disable check constraints before inserting reference data
String driver = obProp.getProperty("bbdd.driver");
String url = obProp.getProperty("bbdd.rdbms").equals("POSTGRE") ? obProp
.getProperty("bbdd.url") + "/" + obProp.getProperty("bbdd.sid") : obProp
.getProperty("bbdd.url");
String user = obProp.getProperty("bbdd.user");
String password = obProp.getProperty("bbdd.password");
BasicDataSource datasource = DBSMOBUtil.getDataSource(driver, url, user, password);
Platform platform = PlatformFactory.createNewPlatformInstance(datasource);
return platform;
}
示例9: main
import org.apache.ddlutils.PlatformFactory; //导入方法依赖的package包/类
public static void main(final String[] args) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("C:\\wamp\\www\\hlx\\Application\\Home\\");
final String basePath = _builder.toString();
DruidDataSource dataSource = new DruidDataSource();
dataSource.setDriverClassName("com.mysql.jdbc.Driver");
dataSource.setUrl("jdbc:mysql://192.168.100.5:3306/xiu?useUnicode=true&characterEncoding=UTF-8");
dataSource.setUsername("root");
dataSource.setPassword("123456");
Platform platform = PlatformFactory.createNewPlatformInstance(dataSource);
Database model = platform.readModelFromDatabase("xiu");
Table[] _tables = model.getTables();
final Function1<Table, Boolean> _function = (Table it) -> {
String _name = it.getName();
return Boolean.valueOf((!Objects.equal(_name, "t_id")));
};
Iterable<Table> _filter = IterableExtensions.<Table>filter(((Iterable<Table>)Conversions.doWrapArray(_tables)), _function);
final Consumer<Table> _function_1 = (Table table) -> {
try {
CharSequence content = Ddl2Html.index(table);
String klassType = ModelSupport.klassType(table);
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append(basePath, "");
_builder_1.append("\\View\\");
_builder_1.append(klassType, "");
_builder_1.append("\\showList.html");
String path = _builder_1.toString();
final File file = new File(path);
Files.createParentDirs(file);
Files.write(content, file, Charsets.UTF_8);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
};
_filter.forEach(_function_1);
}
示例10: main
import org.apache.ddlutils.PlatformFactory; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
try {
java.util.Properties p = new java.util.Properties();
Connection conn = null;
conn =
DriverManager.getConnection("jdbc:gemfirexd://localhost:1527", "app", "app");
// DriverManager.getConnection("jdbc:gemfirexd://camus.vmware.com:1527", "app", "app");
// DriverManager.getConnection("jdbc:timesten:client:sampledbCS_1121", "appuser", "appuser");
// DriverManager.getConnection("jdbc:gemfirexd:;gemfire.mcast-port=33666;gemfire.roles=gemfirexd.client", p);
// DriverManager.getConnection("jdbc:gemfire:gemfirexd:;gemfire.mcast-port=0;gemfire.locators=localhost[4444];gemfire.roles=gemfirexd.client", p);
// DriverManager.getConnection("jdbc:gemfire:gemfirexd:;gemfire.roles=gemfirexd.client;gemfire.mcast-port=0;gemfire.locators=localhost[4444]", p);
// DriverManager.getConnection("jdbc:gemfire:gemfirexd:;gemfire.mcast-port=0;gemfire.locators=localhost[4444]" + ";create=true", p);
// Do something with the Connection
String dbtype = (new PlatformUtils()).determineDatabaseType("com.pivotal.gemfirexd.jdbc.ClientDriver", "jdbc:gemfirexd://localhost:1527");
System.out.println("DB TYPE = " + dbtype);
//Platform platform = PlatformFactory.createNewPlatformInstance("com.pivotal.gemfirexd.jdbc.ClientDriver", "jdbc:gemfirexd://localhost:1527");
Platform platform = PlatformFactory.createNewPlatformInstance("GemFireXD");
Database db = platform.readModelFromDatabase(conn, "model");
//new DatabaseIO().write(db, "DBModel");
FileWriter writer = new FileWriter(new File("DBModel.sql"));
platform.setScriptModeOn(true);
if (platform.getPlatformInfo().isSqlCommentsSupported())
{
// we're generating SQL comments if possible
platform.setSqlCommentsOn(true);
}
platform.getSqlBuilder().setWriter(writer);
platform.getSqlBuilder().createTables(db, true);
writer.close();
System.out.println("Written schema SQL to DBModel.sql" );
} catch (Exception ex) {
ex.printStackTrace();
}
}
示例11: disableConstraints
import org.apache.ddlutils.PlatformFactory; //导入方法依赖的package包/类
private void disableConstraints() throws FileNotFoundException, IOException {
log.info("Disabling constraints...");
String obDir = getProject().getBaseDir().toString() + "/../";
Properties obProp = new Properties();
obProp.load(new FileInputStream(new File(obDir, "config/Openbravo.properties")));
// We disable check constraints before inserting reference data
String driver = obProp.getProperty("bbdd.driver");
String url = obProp.getProperty("bbdd.rdbms").equals("POSTGRE") ? obProp
.getProperty("bbdd.url") + "/" + obProp.getProperty("bbdd.sid") : obProp
.getProperty("bbdd.url");
String user = obProp.getProperty("bbdd.user");
String password = obProp.getProperty("bbdd.password");
BasicDataSource datasource = DBSMOBUtil.getDataSource(driver, url, user, password);
platform = PlatformFactory.createNewPlatformInstance(datasource);
Vector<File> dirs = new Vector<File>();
dirs.add(new File(obDir, "/src-db/database/model/"));
File modules = new File(obDir, "/modules");
for (int j = 0; j < modules.listFiles().length; j++) {
final File dirF = new File(modules.listFiles()[j], "/src-db/database/model/");
if (dirF.exists()) {
dirs.add(dirF);
}
}
File[] fileArray = new File[dirs.size()];
for (int i = 0; i < dirs.size(); i++) {
fileArray[i] = dirs.get(i);
}
xmlModel = DatabaseUtils.readDatabase(fileArray);
Connection con = null;
try {
con = platform.borrowConnection();
log.info(" Disabling foreign keys");
platform.disableAllFK(con, xmlModel, false);
log.info(" Disabling triggers");
platform.disableAllTriggers(con, xmlModel, false);
log.info(" Disabling check constraints");
platform.disableCheckConstraints(xmlModel);
} finally {
if (con != null) {
platform.returnConnection(con);
}
}
}
示例12: getDatabaseAndSqlBuilderPair
import org.apache.ddlutils.PlatformFactory; //导入方法依赖的package包/类
private Pair<Database, SqlBuilder> getDatabaseAndSqlBuilderPair(String schema, DataSource dataSource) {
Platform platform = PlatformFactory.createNewPlatformInstance(dataSource);
return Pair.of(platform.readModelFromDatabase(null, null, caseConverter.convert(schema), null), getDdlSqlBuilder(schema, platform));
}
示例13: run
import org.apache.ddlutils.PlatformFactory; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void run() {
System.out.println("Indexer: Starting Index Target database");
System.out.println("Indexer: Connecting to target database...");
targetDatabaseMock = new TargetDatabaseMock();
try{
// Clear all in the service
AnalyseService service = ServiceProvider.getInstance().getAnalyseService();
service.clearAllTargetMetadata();
// Connect and fetch
TargetConnection targetConnection = ServiceProvider.getInstance().getDaoService().getTargetConnection();
DataSource dataSource = targetConnection.getDataSource();
System.out.println("Indexer: Reading database...");
Platform platform = PlatformFactory.createNewPlatformInstance(dataSource);
JdbcModelReader modelReader = platform.getModelReader();
//Database database = modelReader.getDatabase(targetConnection.getConnection(), targetConnection.getSchema(), null, targetConnection.getSchema(), null);
Database database = targetDatabaseMock.getDatabase();
service.setTargetDatabaseMetadata(database);
// Tables loop
for(Table table : database.getTables()) {
if (Thread.currentThread().isInterrupted()) {
System.out.println("Done: Cancelled!");
return;
}
String tableName = table.getName();
// Add table to list
service.addTargetTable(tableName, table);
// Add columns
ArrayList<Column> columns = new ArrayList<Column>();
Collections.addAll(columns, table.getColumns());
// Add to the service
service.addTargetColumns(table, columns);
}
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("Done: Indexed Target database");
// Get on main thread and call the callback.
javafx.application.Platform.runLater(() -> callback.call(null));
}
示例14: createTables
import org.apache.ddlutils.PlatformFactory; //导入方法依赖的package包/类
/**
* Creates a Structure defined in the global variable structure in the Database
*
* @param dbName Name of the Database
* @throws Exception Throws Exception if Tables couldnt be created
*/
protected void createTables(String dbName) throws Exception {
Platform platform = PlatformFactory.createNewPlatformInstance(dbName);
platform.createTables(connection, structure, false, true);
}