当前位置: 首页>>代码示例>>Java>>正文


Java JDBCDataSource.setParentType方法代码示例

本文整理汇总了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");
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:21,代码来源:SQLTableLazyLoadTest.java

示例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);
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:23,代码来源:RefreshTablesTest.java

示例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());
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:26,代码来源:TestSQLColumn.java

示例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;
  }
 
开发者ID:SQLPower,项目名称:power-matchmaker,代码行数:28,代码来源:MatchMakerSessionContextImpl.java

示例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();
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:40,代码来源:TestSQLDatabase.java


注:本文中的ca.sqlpower.sql.JDBCDataSource.setParentType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。