本文整理汇总了Java中ca.sqlpower.sql.JDBCDataSource.setParentType方法的典型用法代码示例。如果您正苦于以下问题:Java JDBCDataSource.setParentType方法的具体用法?Java JDBCDataSource.setParentType怎么用?Java JDBCDataSource.setParentType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ca.sqlpower.sql.JDBCDataSource
的用法示例。
在下文中一共展示了JDBCDataSource.setParentType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import ca.sqlpower.sql.JDBCDataSource; //导入方法依赖的package包/类
/**
* Sets up a MockJDBC database with one table in it called "table".
*/
@Override
protected void setUp() throws Exception {
logger.debug("=====setUp=====");
super.setUp();
DataSourceCollection<SPDataSource> dscol = new PlDotIni();
JDBCDataSourceType dstype = new JDBCDataSourceType();
dstype.setJdbcDriver("ca.sqlpower.testutil.MockJDBCDriver");
JDBCDataSource ds = new JDBCDataSource(dscol);
ds.setParentType(dstype);
ds.setUrl("jdbc:mock:name=refresh_test&tables=table");
ds.setUser("");
ds.setPass("");
db = new SQLDatabase(ds);
db.getConnection().close(); // just make sure the connection gets made
table = db.getTableByName("table");
}
示例2: setUp
import ca.sqlpower.sql.JDBCDataSource; //导入方法依赖的package包/类
/**
* Sets up a MockJDBC database with nothing in it. Individual tests can specify
* the structure as required.
*/
@Override
protected void setUp() throws Exception {
logger.debug("=====setUp=====");
super.setUp();
DataSourceCollection<SPDataSource> dscol = new PlDotIni();
JDBCDataSourceType dstype = new JDBCDataSourceType();
dstype.setJdbcDriver("ca.sqlpower.testutil.MockJDBCDriver");
JDBCDataSource ds = new JDBCDataSource(dscol);
ds.setParentType(dstype);
ds.setUrl("jdbc:mock:name=refresh_test");
ds.setUser("");
ds.setPass("");
db = new SQLDatabase(ds);
db.getConnection().close(); // just make sure the connection gets made
con = MockJDBCDriver.getConnection("refresh_test");
assertNotNull(con);
}
示例3: testReverseEngineerAutoInc
import ca.sqlpower.sql.JDBCDataSource; //导入方法依赖的package包/类
public void testReverseEngineerAutoInc() throws Exception {
PlDotIni plini = new PlDotIni();
JDBCDataSourceType dst = new JDBCDataSourceType();
dst.setJdbcDriver("ca.sqlpower.testutil.MockJDBCDriver");
plini.addDataSourceType(dst);
JDBCDataSource ds = new JDBCDataSource(plini);
String url = "jdbc:mock:tables=table1" +
"&columns.table1=pkcol,normalcol" +
"&autoincrement_cols=table1.pkcol";
ds.setUrl(url);
ds.setParentType(dst);
ds.setUser("x");
ds.setPass("x");
plini.addDataSource(ds);
SQLDatabase db = new SQLDatabase(ds);
SQLTable t = db.getTableByName("table1");
SQLColumn pkcol = t.getColumnByName("pkcol");
SQLColumn normalcol = t.getColumnByName("normalcol");
assertTrue(pkcol.isAutoIncrement());
assertFalse(normalcol.isAutoIncrement());
}
示例4: makeDefaultDataSource
import ca.sqlpower.sql.JDBCDataSource; //导入方法依赖的package包/类
/**
* Creates a new hsqldb infile database and adds it to the list.
*/
private JDBCDataSource makeDefaultDataSource() {
JDBCDataSource ds = new JDBCDataSource(getPlDotIni());
ds.setName(DEFAULT_REPOSITORY_DATA_SOURCE_NAME);
ds.setPlSchema("public");
ds.setUser("sa");
ds.setPass("");
ds.setUrl("jdbc:hsqldb:file:"+System.getProperty("user.home")+"/.mm/hsql_repository;shutdown=true");
// find HSQLDB parent type
JDBCDataSourceType hsqldbType = null;
for (JDBCDataSourceType type : getPlDotIni().getDataSourceTypes()) {
if ("HSQLDB".equals(type.getName())) {
hsqldbType = type;
break;
}
}
if (hsqldbType == null) {
throw new RuntimeException("HSQLDB Database type is missing in pl.ini");
}
ds.setParentType(hsqldbType);
getPlDotIni().addDataSource(ds);
return ds;
}
示例5: testConnectionsPerThreadAreUnique
import ca.sqlpower.sql.JDBCDataSource; //导入方法依赖的package包/类
public void testConnectionsPerThreadAreUnique() throws Exception{
JDBCDataSource ads = new JDBCDataSource(getPLIni());
ads.setParentType(new JDBCDataSourceType());
ads.getParentType().setJdbcDriver(MockJDBCDriver.class.getName());
ads.setUrl("jdbc:mock:dbmd.catalogTerm=Catalog&dbmd.schemaTerm=Schema&catalogs=farm,yard,zoo&schemas.farm=cow,pig&schemas.yard=cat,robin&schemas.zoo=lion,giraffe&tables.farm.cow=moo&tables.farm.pig=oink&tables.yard.cat=meow&tables.yard.robin=tweet&tables.zoo.lion=roar&tables.zoo.giraffe=***,^%%");
ads.setUser("fake");
ads.setPass("fake");
ads.setDisplayName("test");
db.setDataSource(ads);
class ConnectionGetter implements Runnable {
Connection con;
public void run() {
try {
con = db.getConnection();
} catch (SQLObjectException e) {
e.printStackTrace();
}
}
}
ConnectionGetter cg1 = new ConnectionGetter();
Thread t1 = new Thread(cg1);
ConnectionGetter cg2 = new ConnectionGetter();
Thread t2 = new Thread(cg2);
t1.start();
t2.start();
t1.join();
t2.join();
if (cg1.con == null) fail("cg1 didn't get a connection");
if (cg2.con == null) fail("cg2 didn't get a connection");
assertNotSame("Both threads got the same connection!", cg1.con, cg2.con);
cg1.con.close();
cg2.con.close();
}