List of usage examples for java.sql SQLException SQLException
public SQLException(Throwable cause)
SQLException
object with a given cause
. From source file:com.treasuredata.jdbc.TDDatabaseMetaData.java
public boolean allProceduresAreCallable() throws SQLException { throw new SQLException("Unsupported TDDatabaseMetaData#allProceduresAreCallable()"); }
From source file:edu.upenn.cis.orchestra.obsolete.SchemaConverterJDBC.java
/** * Create the SQL statements necessary to convert the schema's relations so * that they can store labeled nulls./*from w ww . ja va 2s . c om*/ * @param forceConversion If invalid labeled null column exist in the database, try to run the conversion anyway or cancel * @param containsBidirectionalMappings * @return List of relations that already contain labeled null columns but without the correct characteristics */ public Map<Relation, List<String>> runConversion(boolean forceConversion, boolean withLogging, String database, boolean stratified, boolean containsBidirectionalMappings) throws SQLException { List<String> statements = new ArrayList<String>(); try { // HACK!!! Config.setJDBCDriver("db2"); Map<Relation, List<String>> res = _statementsGen.createTableConversionStatements(statements, withLogging, database, stratified, " NOT LOGGED INITIALLY", new SqlDb(null, null, null), containsBidirectionalMappings); if (res.size() == 0 || forceConversion) { for (String statement : statements) { _log.debug("Running query " + statement); System.out.println(statement); _jt.execute(statement); } } return res; } catch (MetaDataAccessException e) { throw new SQLException("Unable to convert"); } }
From source file:io.cloudslang.content.database.utils.SQLUtilsTest.java
@Test public void testToString() { final String toString = SQLUtils.toString(new SQLException("test ex")); assertTrue(toString.startsWith("java.sql.SQLException: test ex")); }
From source file:cz.lbenda.dataman.db.DatamanDataSource.java
@Override public <T> T unwrap(Class<T> iface) throws SQLException { getLogWriter().print("This data source didn't implement wraping and unwraping"); throw new SQLException("This data source didn't implement wraping and unwraping"); }
From source file:org.apache.jena.jdbc.remote.statements.RemoteEndpointStatement.java
@Override protected QueryExecution createQueryExecution(Query q) throws SQLException { if (this.remoteConn.getQueryEndpoint() == null) throw new SQLException( "This statement is backed by a write-only connection, read operations are not supported"); // Create basic execution QueryEngineHTTP exec = (QueryEngineHTTP) QueryExecutionFactory .sparqlService(this.remoteConn.getQueryEndpoint(), q); // Apply HTTP settings if (this.client != null) { exec.setClient(client);//from w ww .j a v a 2 s . co m } // Apply default and named graphs if appropriate if (this.remoteConn.getDefaultGraphURIs() != null) { exec.setDefaultGraphURIs(this.remoteConn.getDefaultGraphURIs()); } if (this.remoteConn.getNamedGraphURIs() != null) { exec.setNamedGraphURIs(this.remoteConn.getNamedGraphURIs()); } // Set result types if (this.remoteConn.getSelectResultsType() != null) { exec.setSelectContentType(this.remoteConn.getSelectResultsType()); } if (this.remoteConn.getModelResultsType() != null) { exec.setModelContentType(this.remoteConn.getModelResultsType()); } // Return execution return exec; }
From source file:com.aionemu.commons.database.PoolableConnectionFactoryAE.java
/** * Validate connection by checking if connection is not closed and is still valid. throws SQLException if connection * is invalid.//from w w w .ja va 2 s . c o m */ @Override public void validateConnection(Connection conn) throws SQLException { if (conn.isClosed()) throw new SQLException("validateConnection: connection closed"); if (validationTimeout >= 0 && !conn.isValid(validationTimeout)) throw new SQLException("validateConnection: connection invalid"); }
From source file:com.javacreed.secureproperties.utils.DbHelper.java
/** * * @param query/*www . ja v a2 s.c om*/ * @return * @throws SQLException */ public String queryForSingleValue(final String query) throws SQLException { try (Connection connection = getConnection(); Statement statement = connection.createStatement(); ResultSet resultSet = statement.executeQuery(query);) { if (resultSet.next()) { final String value = resultSet.getString(1); if (resultSet.next()) { throw new SQLException("More than one row was returned"); } return value; } } throw new SQLException("No rows were returned"); }
From source file:com.adaptris.jdbc.connection.FailoverConnection.java
/** * Returns the userConnection./*from ww w. j a va 2 s .co m*/ * * @return java.sql.Connection * @throws SQLException on error. */ public synchronized Connection getConnection() throws SQLException { if (!isValid) { throw new SQLException("This connection is no longer valid."); } validateConnection(0); return sqlConnection; }
From source file:jp.co.acroquest.endosnipe.data.db.H2DataSourceCreator.java
/** * {@inheritDoc}// w w w .j a v a 2 s . c o m */ public DataSource createPoolingDataSource(final String dbname, final boolean connectOnlyExists) throws SQLException { try { Class.forName("org.h2.Driver"); String uri = createDatabaseURI(dbname, connectOnlyExists); ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(uri, USER_NAME, PASSWORD); // ????? StackObjectPool ?? // ???????? ConnectionManager manager = ConnectionManager.getInstance(); ObjectPool connectionPool = manager.getConnectionPool(uri); if (connectionPool == null) { connectionPool = manager.createNewConnectionPool(uri); } new PoolableConnectionFactory(connectionFactory, connectionPool, null, null, false, true); return new PoolingDataSource(connectionPool); } catch (Exception ex) { LOGGER.log(EXCEPTION_OCCURED, ex, ex.getMessage()); throw new SQLException(ex.getMessage()); } }
From source file:com.yoncabt.ebr.jdbcbridge.pool.DataSource.java
public EBRConnection connect(String driver, String url, String user, String pass) throws SQLException { try {/*from ww w . ja v a2 s . com*/ DriverManager.registerDriver((Driver) Class.forName(driver).newInstance()); Connection connection = DriverManager.getConnection(url, user, pass); return new EBRConnection(this, connection); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException ex) { throw new SQLException(ex); } }