List of usage examples for java.sql SQLException SQLException
public SQLException(Throwable cause)
SQLException
object with a given cause
. From source file:org.bytesoft.bytejta.supports.jdbc.LocalXADataSource.java
public Connection getConnection(String username, String password) throws SQLException { TransactionXid transactionXid = null; try {//from w w w .java2 s. c om Transaction transaction = (Transaction) this.transactionManager.getTransaction(); if (transaction == null) { return this.dataSource.getConnection(username, password); } transaction.registerTransactionListener(this); transactionXid = transaction.getTransactionContext().getXid(); LocalXAResourceDescriptor descriptor = null; LocalXAResource localRes = null; LogicalConnection connection = this.connections.get(transactionXid); if (connection == null) { LocalXAConnection xacon = this.getXAConnection(username, password); connection = xacon.getConnection(); descriptor = xacon.getXAResource(); localRes = (LocalXAResource) descriptor.getDelegate(); this.connections.put(transactionXid, connection); } if (descriptor != null) { transaction.enlistResource(descriptor); connection.setCloseImmediately(localRes.hasParticipatedTx() == false); } return connection; } catch (SystemException ex) { throw new SQLException(ex); } catch (RollbackException ex) { throw new SQLException(ex); } catch (RuntimeException ex) { throw new SQLException(ex); } }
From source file:com.flexive.core.Database.java
/** * Retrieves a database connection for the global configuration table, regardless * of the current request's division id. * * @return a database connection//from w w w . j av a 2s . c om * @throws SQLException if no connection could be retrieved */ public static Connection getGlobalDbConnection() throws SQLException { try { return getGlobalDataSource().getConnection(); } catch (SQLException exc) { String sErr = "FxDbException, unable to retrieve global DB Connection: " + exc.getMessage(); LOG.error(sErr); throw new SQLException(sErr); } }
From source file:net.sf.farrago.server.FarragoServletCommandSink.java
private void handleRequest(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws ServletException { ObjectInputStream ois = null; ObjectOutputStream oos = null; try {//from w ww . j ava2 s . co m // Get the method to execute String method = httpServletRequest.getHeader(ServletCommandSinkIdentifier.METHOD_IDENTIFIER); if (method != null) { ois = new ObjectInputStream(httpServletRequest.getInputStream()); // And initialize the output OutputStream os = httpServletResponse.getOutputStream(); oos = new ObjectOutputStream(os); Object objectToReturn = null; try { // Some command to process ? if (method.equals(ServletCommandSinkIdentifier.PROCESS_COMMAND)) { // Read parameter objects Long connuid = (Long) ois.readObject(); Long uid = (Long) ois.readObject(); Command cmd = (Command) ois.readObject(); CallingContext ctx = (CallingContext) ois.readObject(); // Delegate execution to the CommandProcessor objectToReturn = processor.process(connuid, uid, cmd, ctx); } else if (method.equals(ServletCommandSinkIdentifier.CONNECT_COMMAND)) { String url = ois.readUTF(); Properties props = (Properties) ois.readObject(); Properties clientInfo = (Properties) ois.readObject(); CallingContext ctx = (CallingContext) ois.readObject(); ConnectionConfiguration connectionConfiguration = VJdbcConfiguration.singleton() .getConnection(url); if (connectionConfiguration != null) { Connection conn = connectionConfiguration.create(props); objectToReturn = processor.registerConnection(conn, connectionConfiguration, clientInfo, ctx); } else { objectToReturn = new SQLException("VJDBC-Connection " + url + " not found"); } } } catch (Throwable t) { // Wrap any exception so that it can be transported back to // the client objectToReturn = SQLExceptionHelper.wrap(t); } // Write the result in the response buffer oos.writeObject(objectToReturn); oos.flush(); httpServletResponse.flushBuffer(); } else { // No VJDBC-Method ? Then we redirect the stupid browser user to // some information page :-) httpServletResponse.sendRedirect("index.html"); } } catch (Exception e) { logger.error("Unexpected Exception", e); throw new ServletException(e); } finally { StreamCloser.close(ois); StreamCloser.close(oos); } }
From source file:com.facebook.presto.jdbc.PrestoConnection.java
@Override public void commit() throws SQLException { checkOpen();/*from w w w. ja va 2 s. c o m*/ if (getAutoCommit()) { throw new SQLException("Connection is in auto-commit mode"); } throw new NotImplementedException("Connection", "commit"); }
From source file:edu.lternet.pasta.dml.DataManager.java
public static Connection getConnection() throws SQLException { Connection connection = null; int index = 0; if (connectionPool == null) { throw new SQLException("The Connection Pool is null"); }/*from w ww . j a va 2 s .c om*/ while (index < MAXIMUM_NUMBER_TO_ACCESS_CONNECTIONPOOL) { try { connection = connectionPool.getConnection(); break; } catch (ConnectionNotAvailableException cna) { try { Thread.sleep(SLEEP_TIME); } catch (Exception e) { log.error("Error in DataManager.getConnection(): " + e.getMessage()); } } catch (SQLException sql) { log.error("Error in DataManager.getConnection(): " + sql.getMessage()); } index++; } return connection; }
From source file:com.globalsight.ling.tm3.core.TuStorage.java
/** * Delete a TU, along with all its TUV, attributes, and history. * //from www . j a v a2s . c o m * @param conn * @param tu * @throws SQLException */ public void deleteTu(Connection conn, TM3Tu<T> tu) throws SQLException { try { // tm3_attr_val_shared_xx SQLUtil.exec(conn, new StatementBuilder().append("DELETE FROM ").append(storage.getAttrValTableName()) .append(" WHERE tuId = ?").addValue(tu.getId())); // tm3_tuv_ext_shared_xx SQLUtil.exec(conn, new StatementBuilder().append("DELETE FROM ").append(storage.getTuvExtTableName()) .append(" WHERE tuId = ?").addValue(tu.getId())); // TODO: not care event table // tm3_tuv_shared_xx SQLUtil.exec(conn, new StatementBuilder().append("DELETE FROM ").append(storage.getTuvTableName()) .append(" WHERE tuId = ?").addValue(tu.getId())); // tm3_tu_shared_xx SQLUtil.exec(conn, new StatementBuilder().append("DELETE FROM ").append(storage.getTuTableName()) .append(" WHERE id = ?").addValue(tu.getId())); } catch (Exception e) { throw new SQLException(e); } }
From source file:com.mysoft.b2b.event.util.MysoftBoneCPDataSource.java
/** * @throws SQLException /*from w w w . j a v a 2s . com*/ * * */ private void maybeInit() throws SQLException { this.rwl.readLock().lock(); if (this.pool == null) { this.rwl.readLock().unlock(); this.rwl.writeLock().lock(); if (this.pool == null) { //read might have passed, write might not try { if (this.getDriverClass() != null) { loadClass(this.getDriverClass()); } } catch (ClassNotFoundException e) { throw new SQLException(PoolUtil.stringifyException(e)); } logger.debug(this.toString()); this.pool = new BoneCP(this); } this.rwl.writeLock().unlock(); // Unlock write } else { this.rwl.readLock().unlock(); // Unlock read } }
From source file:org.sakaiproject.orm.ibatis.support.AbstractLobTypeHandler.java
/** * This implementation delegates to getResultInternal, * passing in the LobHandler of this type. * @see #getResultInternal/*from ww w . ja v a2s .c o m*/ */ public final Object getResult(ResultSet rs, int columnIndex) throws SQLException { try { return getResultInternal(rs, columnIndex, this.lobHandler); } catch (IOException ex) { throw new SQLException( "I/O errors during LOB access: " + ex.getClass().getName() + ": " + ex.getMessage()); } }
From source file:gridool.db.dba.DBAccessor.java
public Connection getConnection(@Nonnull String dbName) throws SQLException { final Connection conn; if (primaryDbName.equalsIgnoreCase(dbName)) { conn = getPrimaryDbConnection(); } else {/*from w ww. j a v a2 s . c o m*/ final String replicaDbUrl = dbUrlPrefix + dbName; try { conn = JDBCUtils.getConnection(replicaDbUrl, driverClassName, userName, password); } catch (ClassNotFoundException e) { throw new SQLException(e); } } return conn; }
From source file:com.splicemachine.tutorials.sparkstreaming.kafka.SensorMessageVTI.java
/** * Dynamic MetaData used to dynamically bind a function. * <p>//w w w.j a v a 2s . com * Metadata */ @Override public ResultSetMetaData getMetaData() throws SQLException { throw new SQLException("not supported"); }