List of usage examples for java.sql SQLException getMessage
public String getMessage()
From source file:com.sun.portal.os.portlets.PortletChartUtilities.java
protected static Dataset generatePieDataSet(Connection con, String sql) { JDBCPieDataset data = null;//w w w . j a va2 s . c om try { data = new JDBCPieDataset(con); data.executeQuery(sql); con.close(); } catch (SQLException e) { System.err.print("SQLException: "); System.err.println(e.getMessage()); } catch (Exception e) { System.err.print("Exception: "); System.err.println(e.getMessage()); } return data; }
From source file:com.cws.esolutions.core.listeners.CoreServiceInitializer.java
/** * Shuts down the running core service process. */// w ww .j a v a 2s. com public static void shutdown() { final String methodName = CoreServiceInitializer.CNAME + "#shutdown()"; if (DEBUG) { DEBUGGER.debug(methodName); } final Map<String, DataSource> datasources = CoreServiceInitializer.appBean.getDataSources(); try { if ((datasources != null) && (datasources.size() != 0)) { for (String key : datasources.keySet()) { if (DEBUG) { DEBUGGER.debug("Key: {}", key); } BasicDataSource dataSource = (BasicDataSource) datasources.get(key); if (DEBUG) { DEBUGGER.debug("BasicDataSource: {}", dataSource); } if ((dataSource != null) && (!(dataSource.isClosed()))) { dataSource.close(); } } } } catch (SQLException sqx) { ERROR_RECORDER.error(sqx.getMessage(), sqx); } }
From source file:com.wso2telco.dep.subscriptionvalidator.util.ValidatorDBUtils.java
private static void closeResultSet(ResultSet resultSet) { if (resultSet != null) { try {/* w ww .j ava2 s .com*/ resultSet.close(); } catch (SQLException var2) { log.warn("Database error. Could not close ResultSet - " + var2.getMessage(), var2); } } }
From source file:de.unidue.inf.is.ezdl.dlservices.repository.store.repositories.DBRepository.java
private static void rollback(Connection connection) { try {/*from ww w . j ava 2 s.c o m*/ connection.rollback(); } catch (SQLException e) { logger.error(e.getMessage(), e); } }
From source file:gsn.http.GMLHandler.java
/** * returns null if there is an error.//from w w w.j av a 2s . co m * * @param virtual_sensor_name * @return */ public static ArrayList<StreamElement> getMostRecentValueFor(String virtual_sensor_name) { StringBuilder query = new StringBuilder("select * from ").append(virtual_sensor_name) .append(" where timed = (select max(timed) from ").append(virtual_sensor_name).append(")"); ArrayList<StreamElement> toReturn = new ArrayList<StreamElement>(); try { DataEnumerator result = Main.getStorage(virtual_sensor_name).executeQuery(query, true); while (result.hasMoreElements()) toReturn.add(result.nextElement()); } catch (SQLException e) { logger.error("ERROR IN EXECUTING, query: " + query + ": " + e.getMessage()); return null; } return toReturn; }
From source file:OCCIConnectionServlet.java
public static synchronized Connection checkOut(String baseName) { boolean found = false; OracleConnectionCacheImpl cached = null; Connection connection = null; if (verbose) { System.out/*from w w w. j a v a 2 s.co m*/ .println("There are " + Integer.toString(numberImplementations) + " connections in the cache"); System.out.println("Searching for a matching implementation..."); } for (int i = 0; !found && i < numberImplementations; i++) { if (verbose) { System.out.println("Vector entry " + Integer.toString(i)); } cached = (OracleConnectionCacheImpl) cachedImplementations.get(i); if (cached.getDescription().equals(baseName)) { if (verbose) { System.out.println("found cached entry " + Integer.toString(i) + " for " + baseName); } found = true; } } if (!found) { if (verbose) { System.out.println("Cached entry not found "); System.out.println("Allocating new entry for " + baseName); } try { cached = new OracleConnectionCacheImpl(getConnectionPoolDataSource(baseName)); cached.setDescription(baseName); cachedImplementations.add(cached); numberImplementations++; } catch (SQLException e) { System.err.println(e.getMessage() + " creating a new implementation for " + baseName); } } if (cached != null) { try { connection = cached.getConnection(); } catch (SQLException e) { System.err.println(e.getMessage() + " getting connection for " + baseName); } } return connection; }
From source file:common.DB.java
public static String getDataAt(String query, int row, String columnName) { try {/*ww w . j av a 2 s . co m*/ DB.getConnection(); statement = connection.createStatement(); resultSet = statement.executeQuery(query); resultSet.absolute(row + 1); String result = resultSet.getString(columnName); close(); return result; } catch (SQLException sqlEx) { System.out.println(sqlEx.getMessage()); close(); return null; } }
From source file:common.DB.java
public static void close() { try {//from ww w . j a v a 2 s.c o m if (resultSet != null) { resultSet.close(); resultSet = null; } if (statement != null) { statement.close(); statement = null; } if (connection != null) { connection.close(); connection = null; } } catch (SQLException sqlEx) { System.out.println(sqlEx.getMessage()); } }
From source file:com.wso2telco.util.DbUtil.java
public static String getContextIDForHashKey(String hashKey) throws AuthenticatorException, SQLException { String sessionDataKey = null; String sql = "select contextid from sms_hashkey_contextid_mapping where hashkey=?"; Connection connection = null; PreparedStatement ps = null;/*from w ww. ja v a 2s .com*/ ResultSet rs = null; try { connection = getConnectDBConnection(); ps = connection.prepareStatement(sql); ps.setString(1, hashKey); rs = ps.executeQuery(); while (rs.next()) { sessionDataKey = rs.getString("contextid"); } } catch (SQLException e) { handleException(e.getMessage(), e); } finally { IdentityDatabaseUtil.closeAllConnections(connection, rs, ps); } return sessionDataKey; }
From source file:de.mendelson.comm.as2.database.DBDriverManager.java
/**Returns a connection to the database *//*w w w . j a v a2 s . c o m*/ public static Connection getConnection(final int DB_TYPE, String hostName) { try { return (getConnectionWithoutErrorHandling(DB_TYPE, hostName)); } catch (SQLException e) { Logger.getLogger(AS2Server.SERVER_LOGGER_NAME).severe(e.getMessage()); } return (null); }