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


Java JDBCDataSource.setUrl方法代码示例

本文整理汇总了Java中ca.sqlpower.sql.JDBCDataSource.setUrl方法的典型用法代码示例。如果您正苦于以下问题:Java JDBCDataSource.setUrl方法的具体用法?Java JDBCDataSource.setUrl怎么用?Java JDBCDataSource.setUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ca.sqlpower.sql.JDBCDataSource的用法示例。


在下文中一共展示了JDBCDataSource.setUrl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: testPopulateCatalogsSchemasAndTables

import ca.sqlpower.sql.JDBCDataSource; //导入方法依赖的package包/类
public void testPopulateCatalogsSchemasAndTables() throws Exception {
    JDBCDataSource ds = new JDBCDataSource(getPLIni());
    ds.setDisplayName("catalogsSchemasAndTables");
    ds.getParentType().setJdbcDriver(MockJDBCDriver.class.getName());
    ds.setUser("fake");
    ds.setPass("fake");
    ds.setUrl("jdbc:mock:dbmd.catalogTerm=Catalog&dbmd.schemaTerm=Schema" +
            "&catalogs=cat1" +
            "&schemas.cat1=sch1" +
            "&tables.cat1.sch1=tab1");
    SQLDatabase db = new SQLDatabase(ds);
    db.populate();
    assertEquals(1, db.getChildCount());
    assertTrue(db.allowsChildType(SQLCatalog.class));
    assertEquals(db.getChild(0).getName(), "cat1");
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:17,代码来源:TestSQLDatabase.java

示例4: testBadURLConnect

import ca.sqlpower.sql.JDBCDataSource; //导入方法依赖的package包/类
public void testBadURLConnect() throws Exception {
		JDBCDataSource ds = db.getDataSource();
		ds.setUrl("jdbc:bad:moo");
		
		SQLDatabase mydb = new SQLDatabase(ds);
		Connection con = null;
		SQLObjectException exc = null;
		try {
			assertFalse("db shouldn't have been connected yet", db.isConnected());
			con = mydb.getConnection();
		} catch (SQLObjectException e) {
			exc = e;
		}
		assertNotNull("should have got an ArchitectException", exc);
//		XXX: this test should be re-enabled when the product has I18N implemented.
		//assertEquals("error message should have been dbconnect.connectionFailed", "dbconnect.connectionFailed", exc.getMessage());
		if (con != null) con.close();  // con should be null, but if it isn't we have to put it back in the pool.
		assertNull("connection should be null", con);
	}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:20,代码来源:TestSQLDatabase.java

示例5: 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

示例6: testResultTableExistsWhenFalse

import ca.sqlpower.sql.JDBCDataSource; //导入方法依赖的package包/类
/**
 * Tests that new nonexistant handcrafted tables are nonexistant according
 * to the Project object.
 */
public void testResultTableExistsWhenFalse() throws Exception {
	JDBCDataSource ds = new JDBCDataSource(new PlDotIni());
	ds.getParentType().setJdbcDriver(MockJDBCDriver.class.getName());
	ds
			.setUrl("jdbc:mock:dbmd.catalogTerm=Catalog&dbmd.schemaTerm=Schema&catalogs=farm&schemas.farm=cow&tables.farm.cow=moo");
	ds.setUser("n/a");
	ds.setPass("n/a");
	final SQLDatabase db = new SQLDatabase(ds);
	session.setDatabase(db);
	SQLCatalog farmCat = db.getChildByName("farm", SQLCatalog.class);
	SQLSchema cowSchem = farmCat.getChildByName("cow", SQLSchema.class);
	SQLTable resultTable = new SQLTable(cowSchem, "nonexistant", null,
			"TABLE", true);
	project.setResultTable(resultTable);
	assertFalse(project.doesResultTableExist());
}
 
开发者ID:SQLPower,项目名称:power-matchmaker,代码行数:21,代码来源:ProjectTest.java

示例7: testResultTableExistsWhenInMemoryButStillFalse

import ca.sqlpower.sql.JDBCDataSource; //导入方法依赖的package包/类
/**
 * Tests that new nonexistant simulated tables that are really in the
 * session's in-memory view of the database are nonexistant according to the
 * Project object.
 */
public void testResultTableExistsWhenInMemoryButStillFalse()
		throws Exception {
    JDBCDataSource ds = new JDBCDataSource(new PlDotIni());
	ds.getParentType().setJdbcDriver(MockJDBCDriver.class.getName());
	ds
			.setUrl("jdbc:mock:dbmd.catalogTerm=Catalog&dbmd.schemaTerm=Schema&catalogs=farm&schemas.farm=cow&tables.farm.cow=moo");
	ds.setUser("n/a");
	ds.setPass("n/a");
	final SQLDatabase db = new SQLDatabase(ds);
	session.setDatabase(db);
	SQLTable resultTable = SQLObjectUtils.addSimulatedTable(db, "cat",
			"sch", "faketab");
	project.setResultTable(resultTable);
	assertFalse(project.doesResultTableExist());
}
 
开发者ID:SQLPower,项目名称:power-matchmaker,代码行数:21,代码来源:ProjectTest.java

示例8: testSourceTableExistsWhenFalse

import ca.sqlpower.sql.JDBCDataSource; //导入方法依赖的package包/类
/**
 * Tests that new nonexistant handcrafted tables are nonexistant according
 * to the Project object.
 */
public void testSourceTableExistsWhenFalse() throws Exception {
    JDBCDataSource ds = new JDBCDataSource(new PlDotIni());
	ds.getParentType().setJdbcDriver(MockJDBCDriver.class.getName());
	ds
			.setUrl("jdbc:mock:dbmd.catalogTerm=Catalog&dbmd.schemaTerm=Schema&catalogs=farm&schemas.farm=cow&tables.farm.cow=moo");
	ds.setUser("n/a");
	ds.setPass("n/a");
	final SQLDatabase db = new SQLDatabase(ds);
	session.setDatabase(db);
	SQLCatalog farmCat = db.getChildByName("farm", SQLCatalog.class);
	SQLSchema cowSchem = farmCat.getChildByName("cow", SQLSchema.class);
	SQLTable sourceTable = new SQLTable(cowSchem, "nonexistant", null,
			"TABLE", true);
	project.setSourceTable(sourceTable);
	assertFalse(project.doesSourceTableExist());
}
 
开发者ID:SQLPower,项目名称:power-matchmaker,代码行数:21,代码来源:ProjectTest.java

示例9: testSourceTableExistsWhenInMemoryButStillFalse

import ca.sqlpower.sql.JDBCDataSource; //导入方法依赖的package包/类
/**
 * Tests that new nonexistant simulated tables that are really in the
 * session's in-memory view of the database are nonexistant according to the
 * Project object.
 */
public void testSourceTableExistsWhenInMemoryButStillFalse()
		throws Exception {
    JDBCDataSource ds = new JDBCDataSource(new PlDotIni());
	ds.getParentType().setJdbcDriver(MockJDBCDriver.class.getName());
	ds.setUrl("jdbc:mock:dbmd.catalogTerm=Catalog&dbmd.schemaTerm=Sc" +
			"hema&catalogs=farm&schemas.farm=cow&tables.farm.cow=moo");
	ds.setUser("n/a");
	ds.setPass("n/a");
	final SQLDatabase db = new SQLDatabase(ds);
	session.setDatabase(db);
	SQLTable sourceTable = SQLObjectUtils.addSimulatedTable(db, "cat",
			"sch", "faketab");
	project.setSourceTable(sourceTable);
	assertFalse(project.doesSourceTableExist());
}
 
开发者ID:SQLPower,项目名称:power-matchmaker,代码行数:21,代码来源:ProjectTest.java

示例10: 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

示例11: testPopulateTablesOnly

import ca.sqlpower.sql.JDBCDataSource; //导入方法依赖的package包/类
public void testPopulateTablesOnly() throws Exception {
    JDBCDataSource ds = new JDBCDataSource(getPLIni());
    ds.setDisplayName("tablesOnly");
    ds.getParentType().setJdbcDriver(MockJDBCDriver.class.getName());
    ds.setUser("fake");
    ds.setPass("fake");
    ds.setUrl("jdbc:mock:tables=tab1");
    SQLDatabase db = new SQLDatabase(ds);
    db.populate();
    assertEquals(1, db.getChildCount());
    assertTrue(db.allowsChildType(SQLTable.class));
    assertEquals(db.getChild(0).getName(), "tab1");
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:14,代码来源:TestSQLDatabase.java

示例12: testPopulateSchemasAndTables

import ca.sqlpower.sql.JDBCDataSource; //导入方法依赖的package包/类
public void testPopulateSchemasAndTables() throws Exception {
    JDBCDataSource ds = new JDBCDataSource(getPLIni());
    ds.setDisplayName("schemasAndTables");
    ds.getParentType().setJdbcDriver(MockJDBCDriver.class.getName());
    ds.setUser("fake");
    ds.setPass("fake");
    ds.setUrl("jdbc:mock:dbmd.schemaTerm=Schema&schemas=sch1&tables.sch1=tab1");
    SQLDatabase db = new SQLDatabase(ds);
    db.populate();
    assertEquals(1, db.getChildCount());
    assertTrue(db.allowsChildType(SQLSchema.class));
    assertEquals(db.getChild(0).getName(), "sch1");
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:14,代码来源:TestSQLDatabase.java

示例13: testPopulateCatalogsAndTables

import ca.sqlpower.sql.JDBCDataSource; //导入方法依赖的package包/类
public void testPopulateCatalogsAndTables() throws Exception {
    JDBCDataSource ds = new JDBCDataSource(getPLIni());
    ds.setDisplayName("catalogsAndTables");
    ds.getParentType().setJdbcDriver(MockJDBCDriver.class.getName());
    ds.setUser("fake");
    ds.setPass("fake");
    ds.setUrl("jdbc:mock:dbmd.catalogTerm=Catalog&catalogs=cat1&tables.cat1=tab1");
    SQLDatabase db = new SQLDatabase(ds);
    db.populate();
    assertEquals(1, db.getChildCount());
    assertTrue(db.allowsChildType(SQLCatalog.class));
    assertEquals(db.getChild(0).getName(), "cat1");
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:14,代码来源:TestSQLDatabase.java

示例14: 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

示例15: testPopulateColumnsCaseSensitive

import ca.sqlpower.sql.JDBCDataSource; //导入方法依赖的package包/类
public void testPopulateColumnsCaseSensitive() throws Exception {
    JDBCDataSource ds = new JDBCDataSource(getPLIni());
    ds.setDisplayName("tableWithMixedColumnCase");
    ds.getParentType().setJdbcDriver(MockJDBCDriver.class.getName());
    ds.setUser("fake");
    ds.setPass("fake");
    ds.setUrl("jdbc:mock:" +
            "tables=tab1" +
            "&columns.tab1=this_is_my_column,THIS_IS_MY_COLUMN");
    SQLDatabase db = new SQLDatabase(ds);
    SQLTable t = db.getTableByName("tab1");
    
    // this shouldn't throw a DuplicateColumnException
    assertEquals(2, t.getColumns().size());
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:16,代码来源:TestSQLTable.java


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