List of usage examples for java.sql SQLException getMessage
public String getMessage()
From source file:Accounts.java
public void connectToDB() { try {//from w w w . j a v a2 s .com connection = DriverManager .getConnection("jdbc:mysql://192.168.1.25/accounts?user=spider&password=spider"); } catch (SQLException connectException) { System.out.println(connectException.getMessage()); System.out.println(connectException.getSQLState()); System.out.println(connectException.getErrorCode()); } }
From source file:org.mybatis.spring.AbstractMyBatisSpringTest.java
protected void assertConnectionClosed(MockConnection connection) { try {/*from w w w .jav a 2s. c om*/ if ((connection != null) && !connection.isClosed()) { fail("Connection is not closed"); } } catch (SQLException sqle) { fail("cannot call Connection.isClosed() " + sqle.getMessage()); } }
From source file:com.bt.aloha.testing.DbTestCase.java
public void clearCollection() { try {/*from w ww .ja v a2 s. c om*/ log.debug("Destroying data from StateInfo table"); int count = jdbcHelper.clearTable(ds, "StateInfo"); log.debug(String.format("deleted %d rows", count)); } catch (SQLException e) { log.warn(String.format("Error clearing database: %s", e.getMessage())); } }
From source file:net.orpiske.ssps.sdm.main.DbInitializationHelper.java
private void initializeSoftwareInventory() throws SQLException, DatabaseInitializationException { SoftwareInventoryDao inventory = new SoftwareInventoryDao(databaseManager); try {//from ww w . j a v a 2s. c om inventory.getCount(); } catch (SQLException e) { String err = e.getMessage(); if (StringUtils.containsIgnoreCase(err, "does not exist")) { inventory.createTable(); logger.debug("Software inventory table created successfully"); } else { throw e; } } }
From source file:net.orpiske.ssps.sdm.main.DbInitializationHelper.java
private void initializePackageCache() throws SQLException, DatabaseInitializationException { PackageCacheDao dao = new PackageCacheDao(databaseManager); try {/*from w w w . ja va2s. co m*/ dao.getCount(); } catch (SQLException e) { String err = e.getMessage(); if (StringUtils.containsIgnoreCase(err, "does not exist")) { dao.createTable(); logger.debug("Package cache table created successfully"); } else { throw e; } } }
From source file:net.orpiske.ssps.sdm.main.DbInitializationHelper.java
private void initializeDependencyCache() throws SQLException, DatabaseInitializationException { DependencyCacheDao dao = new DependencyCacheDao(databaseManager); try {/*w w w.j av a2 s. co m*/ dao.getCount(); } catch (SQLException e) { String err = e.getMessage(); if (StringUtils.containsIgnoreCase(err, "does not exist")) { dao.createTable(); logger.debug("Dependency cache table created successfully"); } else { throw e; } } }
From source file:net.certifi.audittablegen.HsqldbDMRTest.java
@Before public void setUp() { dataSource.setDriverClassName("org.hsqldb.jdbcDriver"); dataSource.setUsername("sa"); dataSource.setPassword(""); dataSource.setUrl("jdbc:hsqldb:mem:aname"); dataSource.setMaxActive(10);//from www. j a v a2s .c o m dataSource.setMaxIdle(5); dataSource.setInitialSize(5); dataSource.setValidationQuery("SELECT 1 FROM INFORMATION_SCHEMA.SYSTEM_USERS"); try { hsqldbDMR = new HsqldbDMR(dataSource); } catch (SQLException ex) { logger.error("failed to create dataSource for test class: " + ex.getMessage()); } }
From source file:fll.web.developer.ReplaceChallengeDescriptor.java
protected void processRequest(final HttpServletRequest request, final HttpServletResponse response, final ServletContext application, final HttpSession session) throws IOException, ServletException { if (LOGGER.isTraceEnabled()) { LOGGER.trace("Top of ReplaceChallengeDescriptor.doPost"); }/* ww w . ja v a 2 s . c o m*/ final StringBuilder message = new StringBuilder(); Connection connection = null; try { final DataSource datasource = ApplicationAttributes.getDataSource(application); connection = datasource.getConnection(); final Document curDoc = ApplicationAttributes.getChallengeDocument(application); // must be first to ensure the form parameters are set UploadProcessor.processUpload(request); // create a new empty database from an XML descriptor final FileItem xmlFileItem = (FileItem) request.getAttribute("xmldoc"); final Document newDoc = ChallengeParser .parse(new InputStreamReader(xmlFileItem.getInputStream(), Utilities.DEFAULT_CHARSET)); final String compareMessage = ChallengeParser.compareStructure(curDoc, newDoc); if (null == compareMessage) { GenerateDB.insertOrUpdateChallengeDocument(newDoc, connection); application.setAttribute(ApplicationAttributes.CHALLENGE_DOCUMENT, newDoc); message.append("<p><i>Successfully replaced challenge descriptor</i></p>"); } else { message.append("<p class='error'>"); message.append(compareMessage); message.append("</p>"); } } catch (final FileUploadException fue) { message.append("<p class='error'>Error handling the file upload: " + fue.getMessage() + "</p>"); LOGGER.error(fue, fue); } catch (final SQLException sqle) { message.append("<p class='error'>Error talking to the database: " + sqle.getMessage() + "</p>"); LOGGER.error(sqle, sqle); throw new RuntimeException("Error talking to the database", sqle); } finally { SQLFunctions.close(connection); } if (LOGGER.isTraceEnabled()) { LOGGER.trace("Top of ReplaceChallengeDescriptor.doPost"); } session.setAttribute("message", message.toString()); response.sendRedirect(response.encodeRedirectURL("index.jsp")); }
From source file:xyz.vopen.passport.commons.jdbc.JdbcTemplate.java
/** * ?????(??)//from w w w . ja v a 2s . c om */ protected Object query(String sql, Object[] params, ResultSetHandler handler) { Connection conn = null; try { conn = getConnection(); // logger.info("dbutils.query??"); return queryRunner.query(conn, sql, handler, params); // return queryRunner.query(conn, sql, params, handler); } catch (SQLException t) { System.out.println("??" + t.getMessage()); throw new DataIntegrityViolationException(t.getMessage()); } finally { DataSourceUtils.releaseConnection(conn, this.getDataSource()); // logger.info("dbutils.query?"); } }
From source file:fll.web.report.StoreNonNumericNominees.java
@Override protected void processRequest(final HttpServletRequest request, final HttpServletResponse response, final ServletContext application, final HttpSession session) throws IOException, ServletException { final StringBuilder message = new StringBuilder(); Connection connection = null; try {/*from www.j av a 2 s. c o m*/ final DataSource datasource = ApplicationAttributes.getDataSource(application); connection = datasource.getConnection(); final int tournament = Queries.getCurrentTournament(connection); // get parameters final String nomineesStr = request.getParameter("non-numeric-nominees_data"); if (null == nomineesStr || "".equals(nomineesStr)) { throw new FLLRuntimeException("Parameter 'non-numeric-nominees_data' cannot be null"); } // decode JSON final ObjectMapper jsonMapper = new ObjectMapper(); final Collection<NonNumericNominees> nominees = jsonMapper.readValue(nomineesStr, NonNumericNomineesTypeInformation.INSTANCE); for (final NonNumericNominees nominee : nominees) { nominee.store(connection, tournament); } message.append("<p id='success'>Non-numeric nominees saved to the database</p>"); } catch (final SQLException e) { message.append("<p class='error'>Error saving non-numeric nominees into the database: " + e.getMessage() + "</p>"); LOGGER.error(e, e); throw new RuntimeException("Error saving subjective data into the database", e); } session.setAttribute("message", message.toString()); response.sendRedirect(response.encodeRedirectURL("non-numeric-nominees.jsp")); }