List of usage examples for java.sql SQLException toString
public String toString()
From source file:es.us.mwm.testcloudfoundry.DBClient.java
public DBClient() { try {//from w ww. ja v a 2 s . c o m JsonNode rootNode = new ObjectMapper().readTree(System.getenv("VCAP_SERVICES")); JsonNode innerNode = rootNode.get("cleardb").get(0); if (innerNode != null) { JsonNode aField = innerNode.get("credentials"); if (aField != null) { String host = aField.get("hostname").asText(); String database = aField.get("name").asText(); String username = aField.get("username").asText(); String password = aField.get("password").asText(); conn = DriverManager.getConnection("jdbc:mysql://" + host + ":3306/" + database, username, password); } } } catch (SQLException ex) { log.log(Level.SEVERE, ex.toString(), ex); } catch (IOException ex) { log.log(Level.SEVERE, ex.toString(), ex); } }
From source file:es.us.mwm.testcloudfoundry.DBClient.java
public String getClients() { String result = ""; try {/* w w w .j a va2 s .c o m*/ Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery("SELECT * FROM Client"); result += "<table>"; result += "<tr><th>IDCLIENT</th><th>NAME</th></tr>"; while (rs.next()) { result += "<tr>"; result += "<td>" + rs.getInt("idClient") + "</td>"; result += "<td>" + rs.getString("Address") + "</td>"; result += "<td>" + rs.getString("Name") + "</td>"; result += "</tr>"; } result += "</table>"; rs.close(); stmt.close(); } catch (SQLException ex) { log.log(Level.SEVERE, ex.toString(), ex); } return result; }
From source file:com.cloudera.sqoop.manager.TestHsqldbManager.java
@After public void tearDown() { try {/*from www . ja v a 2s. c o m*/ manager.close(); } catch (SQLException sqlE) { LOG.error("Got SQLException: " + sqlE.toString()); fail("Got SQLException: " + sqlE.toString()); } }
From source file:com.cloudera.sqoop.manager.TestHsqldbManager.java
@Before public void setUp() { testServer = new HsqldbTestServer(); try {//from w w w .jav a 2 s . c om testServer.resetServer(); } catch (SQLException sqlE) { LOG.error("Got SQLException: " + sqlE.toString()); fail("Got SQLException: " + sqlE.toString()); } catch (ClassNotFoundException cnfe) { LOG.error("Could not find class for db driver: " + cnfe.toString()); fail("Could not find class for db driver: " + cnfe.toString()); } manager = testServer.getManager(); }
From source file:it.unibas.spicy.persistence.relational.SimpleDbConnectionFactory.java
public void close(Connection connection) { try {// w ww. j a v a2s . c o m if (connection != null) { connection.close(); } } catch (SQLException sqle) { logger.fatal(sqle.toString()); } }
From source file:it.unibas.spicy.persistence.relational.SimpleDbConnectionFactory.java
public void close(Statement statement) { try {//w w w. j a v a2s. co m if (statement != null) { statement.close(); } } catch (SQLException sqle) { logger.fatal(sqle.toString()); } }
From source file:it.unibas.spicy.persistence.relational.SimpleDbConnectionFactory.java
public void close(ResultSet resultSet) { try {/*from www . j a v a2 s. c o m*/ if (resultSet != null) { resultSet.close(); } } catch (SQLException sqle) { logger.fatal(sqle.toString()); } }
From source file:io.github.retz.scheduler.AdminConsole.java
@Override public String createUser() { LOG.info("AdminConsole.createUser()"); try {/*w w w. ja v a 2s .c o m*/ User user = Database.getInstance().createUser(); return maybeEncodeAsJSON(user); } catch (SQLException e) { return errorJSON(e.toString()); } }
From source file:org.accada.epcis.repository.query.QueryOperationsSession.java
public void close() throws SQLException { for (PreparedStatement ps : namedStatements.values()) { try {/* ww w. j a va2 s .c o m*/ ps.close(); } catch (SQLException e) { LOG.warn("Error closing prepared statement: " + e.toString() + ". Will continue ... "); } } connection.close(); LOG.debug("Database connection for session closed"); }
From source file:io.github.retz.db.Jobs.java
public void doRetry(List<Integer> ids) { try {//from www . j a va2 s . co m for (int id : ids) { Optional<Job> maybeJob = getJob(id); if (maybeJob.isPresent()) { Job job = maybeJob.get(); job.doRetry(); updateJob(job); } } } catch (SQLException e) { LOG.error(e.toString()); } catch (IOException e) { LOG.error(e.toString()); // TODO: do we fail? } }