List of usage examples for java.sql SQLException SQLException
public SQLException(Throwable cause)
SQLException
object with a given cause
. From source file:com.nabla.wapp.server.database.TomcatConnectionPool.java
/** * Constructor/*from w ww.j av a2s . c o m*/ * @param dbName - database name as defined in pool * @throws SQLException */ public TomcatConnectionPool(final String dbName) throws SQLException { Assert.argumentNotNull(dbName, "Have you set the database name in your web.xml file?"); try { final Context initContext = new InitialContext(); final Context ctx = (Context) initContext.lookup("java:/comp/env"); dataSource = (DataSource) ctx.lookup("jdbc/" + dbName); } catch (NamingException e) { if (log.isDebugEnabled()) log.debug("fail to get datasource '" + dbName + "'", e); throw new SQLException("fail to get database '" + dbName + "'"); } }
From source file:com.tera.common.database.dbcp.CPoolableConnectionFactory.java
@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.qubole.quark.catalog.db.encryption.AESEncrypt.java
public String convertToDatabaseColumn(String phrase) throws SQLException { try {// w ww . ja v a2s .co m Cipher encryptCipher = Cipher.getInstance("AES"); encryptCipher.init(Cipher.ENCRYPT_MODE, generateMySQLAESKey(this.key, "UTF-8")); return new String(Hex.encodeHex(encryptCipher.doFinal(phrase.getBytes("UTF-8")))); } catch (Exception e) { throw new SQLException(e); } }
From source file:com.kumarvv.setl.utils.RowSetUtil.java
/** * @return builds and returns source row set *///from www. j a v a2 s . c o m public JdbcRowSet getRowSet(DS ds) throws SQLException { if (ds == null) { throw new SQLException("Invalid DS"); } if (rowSetFactory == null) { rowSetFactory = RowSetProvider.newFactory(); } loadDriver(ds); JdbcRowSet jrs = rowSetFactory.createJdbcRowSet(); jrs.setUrl(ds.getUrl()); jrs.setUsername(ds.getUsername()); jrs.setPassword(ds.getPassword()); return jrs; }
From source file:com.bc.fiduceo.db.AbstractDriver.java
@Override public void open(BasicDataSource dataSource) throws SQLException { try {/*www . j ava2s. c om*/ final java.sql.Driver driverClass = (java.sql.Driver) Class.forName(dataSource.getDriverClassName()) .newInstance(); DriverManager.registerDriver(driverClass); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { throw new SQLException(e.getMessage()); } connection = DriverManager.getConnection(dataSource.getUrl(), dataSource.getUsername(), dataSource.getPassword()); }
From source file:com.wso2telco.mnc.resolver.mncrange.McnRangeDbUtil.java
/** * Gets the axiata db connection.//from w ww.j a v a 2s .c om * * @return the axiata db connection * @throws SQLException the SQL exception * @throws MobileNtException the mobile nt exception */ public static Connection getAxiataDBConnection() throws SQLException, MobileNtException { initializeDatasources(); if (axiataDatasource != null) { return axiataDatasource.getConnection(); } throw new SQLException("Axiata Datasource not initialized properly"); }
From source file:com.taobao.adfs.database.tdhsocket.client.util.ConvertUtil.java
public static short getShortFromString(String stringVal) throws SQLException { if (StringUtils.isBlank(stringVal)) { return 0; }//w ww.ja v a2 s .co m try { int decimalIndex = stringVal.indexOf("."); if (decimalIndex != -1) { double valueAsDouble = Double.parseDouble(stringVal); return (short) valueAsDouble; } return Short.parseShort(stringVal); } catch (NumberFormatException e) { throw new SQLException("Parse integer error:" + stringVal); } }
From source file:org.apache.solr.client.solrj.io.sql.DriverImpl.java
public Connection connect(String url, Properties props) throws SQLException { if (!acceptsURL(url)) { return null; }//from w w w . ja v a2 s. co m URI uri = processUrl(url); loadParams(uri, props); if (!props.containsKey("collection")) { throw new SQLException( "The connection url has no connection properties. At a mininum the collection must be specified."); } String collection = (String) props.remove("collection"); if (!props.containsKey("aggregationMode")) { props.setProperty("aggregationMode", "facet"); } // JDBC requires metadata like field names from the SQLHandler. Force this property to be true. props.setProperty("includeMetadata", "true"); String zkHost = uri.getAuthority() + uri.getPath(); return new ConnectionImpl(url, zkHost, collection, props); }
From source file:net.ageto.gyrex.persistence.jdbc.pool.internal.PoolDataSourceFactory.java
@Override public Driver createDriver(final Properties props) throws SQLException { throw new SQLException("not allowed"); }
From source file:com.taobao.tdhs.jdbc.TDHSPreparedStatement.java
private String mergeSQL() throws SQLException { if (parameters.size() < parameterNumber) { throw new SQLException("Don't have enough parameter!"); }// w ww . j a v a 2s. c om StringBuilder sb = new StringBuilder(); for (int i = 1; i <= parameterNumber; i++) { sb.append(sqlSplited[i - 1]).append(parameters.get(i)); } sb.append(sqlSplited[parameterNumber]); return sb.toString(); }