本文整理汇总了Java中org.apache.ddlutils.PlatformFactory类的典型用法代码示例。如果您正苦于以下问题:Java PlatformFactory类的具体用法?Java PlatformFactory怎么用?Java PlatformFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PlatformFactory类属于org.apache.ddlutils包,在下文中一共展示了PlatformFactory类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: setPlatforms
import org.apache.ddlutils.PlatformFactory; //导入依赖的package包/类
/**
* Specifies the platforms - a comma-separated list of platform names - for which this parameter
* shall be used (see the <code>databaseType</code> attribute of the tasks for possible values).
* For every platform not in this list, the parameter is ignored.
*
* @param platforms The platforms
* @ant.not-required If not specified then the parameter is processed for every platform.
*/
public void setPlatforms(String platforms)
{
_platforms.clear();
if (platforms != null)
{
StringTokenizer tokenizer = new StringTokenizer(platforms, ",");
while (tokenizer.hasMoreTokens())
{
String platform = tokenizer.nextToken().trim();
if (PlatformFactory.isPlatformSupported(platform))
{
_platforms.add(platform.toLowerCase());
}
else
{
throw new IllegalArgumentException("Platform "+platform+" is not supported");
}
}
}
}
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:31,代码来源:Parameter.java
示例2: 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);
}
开发者ID:mauyr,项目名称:openbravo-brazil,代码行数:27,代码来源:SystemValidatorTest.java
示例3: 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);
}
开发者ID:East196,项目名称:maker,代码行数:24,代码来源:Itext2Word.java
示例4: 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);
}
}
开发者ID:Glamdring,项目名称:jvm-monitor,代码行数:19,代码来源:JvmMonitorLoader.java
示例5: 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;
}
开发者ID:Mikescher,项目名称:jClipCorn,代码行数:19,代码来源:DerbyDatabase.java
示例6: 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;
}
开发者ID:Mikescher,项目名称:jClipCorn,代码行数:19,代码来源:DerbyDatabase.java
示例7: 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;
}
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:45,代码来源:PlatformConfiguration.java
示例8: 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);
}
开发者ID:mauyr,项目名称:openbravo-brazil,代码行数:15,代码来源:SystemValidationTask.java
示例9: 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;
}
开发者ID:mauyr,项目名称:openbravo-brazil,代码行数:20,代码来源:SystemService.java
示例10: 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);
}
开发者ID:East196,项目名称:maker,代码行数:37,代码来源:Ddl2Html.java
示例11: 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();
}
}
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:46,代码来源:SimpleTest.java
示例12: 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);
}
}
}
开发者ID:mauyr,项目名称:openbravo-brazil,代码行数:47,代码来源:ImportReferenceDataTask.java
示例13: 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));
}
开发者ID:RapturePlatform,项目名称:Rapture,代码行数:5,代码来源:StandardSqlGenerator.java
示例14: 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));
}
开发者ID:hu-team,项目名称:BusinessRuleGenerator-to,代码行数:53,代码来源:TargetDatabaseTask.java
示例15: getTests
import org.apache.ddlutils.PlatformFactory; //导入依赖的package包/类
/**
* Creates the test suite for the given test class which must be a sub class of
* {@link RoundtripTestBase}. If the platform supports it, it will be tested
* with both delimited and undelimited identifiers.
*
* @param testedClass The tested class
* @return The tests
*/
protected static TestSuite getTests(Class testedClass)
{
if (!RoundtripTestBase.class.isAssignableFrom(testedClass) ||
Modifier.isAbstract(testedClass.getModifiers()))
{
throw new DdlUtilsException("Cannot create parameterized tests for class "+testedClass.getName());
}
TestSuite suite = new TestSuite();
try
{
Method[] methods = testedClass.getMethods();
PlatformInfo info = null;
RoundtripTestBase newTest;
for (int idx = 0; (methods != null) && (idx < methods.length); idx++)
{
if (methods[idx].getName().startsWith("test") &&
((methods[idx].getParameterTypes() == null) || (methods[idx].getParameterTypes().length == 0)))
{
newTest = (RoundtripTestBase)testedClass.newInstance();
newTest.setName(methods[idx].getName());
newTest.setUseDelimitedIdentifiers(false);
suite.addTest(newTest);
if (info == null)
{
info = PlatformFactory.createNewPlatformInstance(newTest.getDatabaseName()).getPlatformInfo();
}
if (info.isDelimitedIdentifiersSupported())
{
newTest = (RoundtripTestBase)testedClass.newInstance();
newTest.setName(methods[idx].getName());
newTest.setUseDelimitedIdentifiers(true);
suite.addTest(newTest);
}
}
}
}
catch (Exception ex)
{
throw new DdlUtilsException(ex);
}
return suite;
}
开发者ID:flex-rental-solutions,项目名称:apache-ddlutils,代码行数:56,代码来源:RoundtripTestBase.java
示例16: 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);
}
开发者ID:Mikescher,项目名称:jClipCorn,代码行数:11,代码来源:DerbyDatabase.java
注:本文中的org.apache.ddlutils.PlatformFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论