?? testddl.java
字號:
package cn.myapps.test;
import junit.framework.TestCase;
import org.apache.commons.beanutils.DynaBean;
import org.apache.commons.dbcp.BasicDataSource;
import org.apache.ddlutils.Platform;
import org.apache.ddlutils.PlatformFactory;
import org.apache.ddlutils.io.DatabaseIO;
import org.apache.ddlutils.model.Column;
import org.apache.ddlutils.model.Database;
import org.apache.ddlutils.model.Table;
import org.apache.ddlutils.platform.oracle.Oracle10Platform;
import org.apache.ddlutils.platform.oracle.Oracle9Platform;
public class TestDDL extends TestCase {
protected void setUp() throws Exception {
super.setUp();
}
protected void tearDown() throws Exception {
super.tearDown();
}
public void testDDL() throws Exception {
/*
* String[] names = PlatformFactory.getSupportedPlatforms(); for (int i =
* 0; i < names.length; i++) { System.out.println(names[i]); }
*/
BasicDataSource ds = new BasicDataSource();
ds.setDriverClassName("oracle.jdbc.driver.OracleDriver");
ds.setUrl("jdbc:oracle:thin:@192.168.0.100:1521:XE");
ds.setUsername("wpigb3");
ds.setPassword("helloworld");
Oracle9Platform oplatform = new Oracle9Platform();
oplatform.setDataSource(ds);
Oracle10Platform platform = new Oracle10Platform();
platform.setDataSource(ds);
// platform.getModelReader().get`
Database db = platform.readModelFromDatabase("XE");
Table[] tables = db.getTables();
System.out.println(tables[0].getName());
/*// "author" is a table of the model
DynaBean author = db.createDynaBeanFor("author", false);
// "name" and "whatever" are columns of table "author"
author.set("name", "James");
author.set("whatever", new Integer(1234));
//platform.insert(db, author);
new DatabaseIO().write(db, "f:/test.xml");*/
/*
* Database db = new Database(); db.setName("test"); Table table = new
* Table(); table.setName("t_test"); db.addTable(table); String fileName =
* "f:/test.xml"; new DatabaseIO().write(db, fileName);
*/
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -