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


Java JDBCDataSource类代码示例

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


JDBCDataSource类属于ca.sqlpower.sql包,在下文中一共展示了JDBCDataSource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testAddAndRemoveQuery

import ca.sqlpower.sql.JDBCDataSource; //导入依赖的package包/类
/**
 * Test a query can be added to and removed from a workspace with the
 * addChild method. Also checks that the index is correct.
 * @throws Exception
 */
public void testAddAndRemoveQuery() throws Exception {
    final JDBCDataSource spds = new JDBCDataSource(new StubDataSourceCollection<SPDataSource>());
    spds.setName("ds");
    WabitDataSource ds = new WabitDataSource(spds);
    workspace.addDataSource(ds);
    
    QueryCache q = new QueryCache(new StubSQLDatabaseMapping());
    q.setName("query");
    
    workspace.addChild(q, 0);
    
    assertTrue(workspace.getChildren().contains(q));
    
    workspace.removeChild(q);
    
    assertFalse(workspace.getChildren().contains(q));
}
 
开发者ID:SQLPower,项目名称:wabit,代码行数:23,代码来源:WabitWorkspaceTest.java

示例2: readPlDotIni

import ca.sqlpower.sql.JDBCDataSource; //导入依赖的package包/类
private static DataSourceCollection<JDBCDataSource> readPlDotIni(String plDotIniPath) throws IOException {
    if (plDotIniPath == null) {
        return null;
    }
    File pf = new File(plDotIniPath);
    if (!pf.exists() || !pf.canRead()) {
        return null;
    }

    DataSourceCollection pld = new PlDotIni();
    // First, read the defaults
    pld.read(SwingSessionContextImpl.class.getClassLoader().getResourceAsStream("ca/sqlpower/sql/default_database_types.ini"));
    // Now, merge in the user's own config
    pld.read(pf);
    return pld;
}
 
开发者ID:SQLPower,项目名称:power-matchmaker,代码行数:17,代码来源:DQguruEngineRunner.java

示例3: commitCurrentDB

import ca.sqlpower.sql.JDBCDataSource; //导入依赖的package包/类
/**
 * If the connection to the database currently selected in the combo box is not in 
 * auto commit mode then any changes will be committed.
 */
private void commitCurrentDB() {
    ConnectionAndStatementBean conBean = conMap.get(databaseMapping.getDatabase((JDBCDataSource) databaseComboBox.getSelectedItem()));
    Connection con = conBean.getConnection();
    if (con == null) {
        return;
    }
    try {
        if (!con.getAutoCommit()) {
            con.commit();
            conBean.setConnectionUncommitted(false);
        }
    } catch (SQLException ex) {
        SPSUtils.showExceptionDialogNoReport(dialogOwner, Messages.getString("SQlQuery.failedCommit"), ex);
    }
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:20,代码来源:SQLQueryUIComponents.java

示例4: testGetGraphNodesForChart

import ca.sqlpower.sql.JDBCDataSource; //导入依赖的package包/类
/**
 * This test confirms that getNodes given a chart will return its query as
 * well.
 * 
 * @throws Exception
 */
public void testGetGraphNodesForChart() throws Exception {
    QueryCache cache = new QueryCache(context);
    cache.setDataSource((JDBCDataSource)session.getDataSources().getDataSource("regression_test"));
    workspace.addQuery(cache, session);
    
    Chart chart = new Chart();
    workspace.addChart(chart);
    chart.setQuery(cache);
    
    WorkspaceGraphModel graphModel = new WorkspaceGraphModel(workspace, chart, false, false);
    Collection<SPObject> nodes = graphModel.getNodes();
    assertEquals(8, nodes.size());
    assertTrue(nodes.contains(cache));
    assertTrue(nodes.contains(chart));
}
 
开发者ID:SQLPower,项目名称:wabit,代码行数:22,代码来源:WorkspaceGraphModelTest.java

示例5: setUp

import ca.sqlpower.sql.JDBCDataSource; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
    super.setUp();
    plIni = new PlDotIni();
    plIni.read(new File("src/test/resources/pl.regression.ini"));
    ds = plIni.getDataSource("regression_test", JDBCDataSource.class);
    db = new SQLDatabase(ds);
    
    final List<SQLObjectItem> items = new ArrayList<SQLObjectItem>();
    TableContainer delegate = new TableContainer("new-id", db, "tableName", "schemaName", "catalogName", items);
    container = new WabitTableContainer(delegate);
    
    QueryCache query = new QueryCache(new StubSQLDatabaseMapping());
    query.addChild(container, 0);
    getWorkspace().addChild(query, 0);
}
 
开发者ID:SQLPower,项目名称:wabit,代码行数:17,代码来源:WabitTableContainerTest.java

示例6: execute

import ca.sqlpower.sql.JDBCDataSource; //导入依赖的package包/类
public void execute() {
	hasStarted = true;
	try {
		Iterator it = driverJarList.iterator();
		while (it.hasNext()) {
			// initialize counters
			jarCount++;
			logger.debug("**************** processing file #" + jarCount + " of " + driverJarList.size()); //$NON-NLS-1$ //$NON-NLS-2$
			String path = (String) it.next();
                  URL jarLocation = JDBCDataSource.jarSpecToFile(path, getClass().getClassLoader(), serverBaseURI);
			if (jarLocation != null) {
                      addJarLocation(jarLocation);
                  }
		}
		finished = true;
		logger.debug("done loading (normal operation), setting finished to true."); //$NON-NLS-1$
	} catch ( Exception exp ) {
		logger.error("something went wrong in LoadJDBCDrivers worker thread!",exp); //$NON-NLS-1$
	} finally {
		finished = true;
		hasStarted = false;
		logger.debug("done loading (error condition), setting finished to true."); //$NON-NLS-1$
	}
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:25,代码来源:JDBCDriverPanel.java

示例7: setUp

import ca.sqlpower.sql.JDBCDataSource; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
	
	collection = new StubDataSourceCollection<JDBCDataSource>();
	firstDSType = new JDBCDataSourceType();
	firstDSType.setJdbcUrl("First Testing URL");
       firstDSType.putProperty(JDBCDataSourceType.SUPPORTS_UPDATEABLE_RESULT_SETS, String.valueOf(true));
	firstDSType.setComment("First testing comment");
	collection.addDataSourceType(firstDSType);
	
	secondDSType = new JDBCDataSourceType();
	secondDSType.setJdbcUrl("Second Testing URL");
	secondDSType.putProperty(JDBCDataSourceType.SUPPORTS_UPDATEABLE_RESULT_SETS, String.valueOf(false));
	secondDSType.setComment("Second testing comment");
	
	editor = new DataSourceTypeEditor(collection, null);
	
	newDSTypePanel = new NewDataSourceTypePanel(editor, collection);
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:20,代码来源:NewDataSourceTypePanelTest.java

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

示例9: testIsPopulateWithCatalogs

import ca.sqlpower.sql.JDBCDataSource; //导入依赖的package包/类
public void testIsPopulateWithCatalogs() throws Exception {		
	JDBCDataSource dataSource = getDb().getDataSource();
	Connection conn = getDb().getConnection();
	DatabaseMetaData meta = conn.getMetaData();
	conn.close();
	conn = null;
	String ct = meta.getCatalogTerm();
	if (null == ct || ct.length() == 0) { // unless this platform has catalogs.
		return;
	}
	SQLCatalog c2 = new SQLCatalog(new SQLDatabase(dataSource),"x");		
	c2.setPopulated(false);			
	c2.populate();			
	assertTrue(c2.isPopulated());			
	c2.setPopulated(true);
	c2.populate();
	assertTrue(c2.isPopulated());
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:19,代码来源:TestSQLCatalog.java

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

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

示例12: testMissingDriverConnect

import ca.sqlpower.sql.JDBCDataSource; //导入依赖的package包/类
public void testMissingDriverConnect() throws SQLException {
	JDBCDataSource ds = db.getDataSource();
	ds.getParentType().setJdbcDriver("ca.sqlpower.xxx.does.not.exist");
	
	SQLDatabase mydb = new SQLDatabase(ds);
	Connection con = null;
	SQLObjectException exc = null;
	try {
		assertFalse("db shouldn't have been connected yet", mydb.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.noDriver", "dbconnect.noDriver", exc.getMessage());
	if (con != null) con.close(); // but we think it's null
	assertNull("connection should be null", con);
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:20,代码来源:TestSQLDatabase.java

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

示例14: testBadPasswordConnect

import ca.sqlpower.sql.JDBCDataSource; //导入依赖的package包/类
public void testBadPasswordConnect() throws SQLException {
	JDBCDataSource ds = db.getDataSource();
	ds.setPass("foofoofoofoofooSDFGHJK");  // XXX: if this is the password, we lose.
	
	SQLDatabase mydb = new SQLDatabase(ds);
	Connection con = null;
	SQLObjectException exc = null;
	try {
		assertFalse("db shouldn't have been connected yet", mydb.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(); // but we hope it's null
	assertNull("connection should be null", con);
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:20,代码来源:TestSQLDatabase.java

示例15: testGetOutboundEdgesForChart

import ca.sqlpower.sql.JDBCDataSource; //导入依赖的package包/类
/**
 * This test confirms that getOutboundEdges given a chart will return its
 * edge to its query.
 * 
 * @throws Exception
 */
public void testGetOutboundEdgesForChart() throws Exception {
    QueryCache cache = new QueryCache(context);
    cache.setDataSource((JDBCDataSource)session.getDataSources().getDataSource("regression_test"));
    workspace.addQuery(cache, session);
    
    Chart chart = new Chart();
    workspace.addChart(chart);
    chart.setQuery(cache);
    
    WorkspaceGraphModel graphModel = new WorkspaceGraphModel(workspace, chart, false, false);
    Collection<WorkspaceGraphModelEdge> outboundEdges = 
         graphModel.getOutboundEdges(chart);
    assertEquals(1, outboundEdges.size());
    WorkspaceGraphModelEdge edge = (WorkspaceGraphModelEdge) outboundEdges.toArray()[0];
    assertEquals(chart, edge.getParent());
    assertEquals(cache, edge.getChild());
}
 
开发者ID:SQLPower,项目名称:wabit,代码行数:24,代码来源:WorkspaceGraphModelTest.java


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