List of usage examples for java.sql SQLException printStackTrace
public void printStackTrace()
From source file:fr.eurecom.nerd.api.rest.Document.java
@GET @RolesAllowed({ "user" }) @Path("/{idDocument}") @Produces(MediaType.APPLICATION_JSON)// w w w.ja v a 2s . c om public Response doGetJSON(@PathParam("idDocument") int idDocument) { LogFactory.logger.info("plain text of article id=" + idDocument + " is required"); ResponseBuilder response = Response.status(Response.Status.OK); String json = null; try { //check first if this uri already exist in our storage TDocument article = sql.selectDocument(idDocument); json = gson.toJson(article); } catch (SQLException e) { e.printStackTrace(); } catch (LanguageException e) { return Response.status(Status.NOT_ACCEPTABLE).header("Access-Control-Allow-Origin", "*") .entity(e.getMessage()).build(); } response.header("Access-Control-Allow-Origin", "*"); response.entity(json + "\n"); return response.build(); }
From source file:com.persistent.cloudninja.utils.TenantProfileUtility.java
/** * Deletes Member records from Member for the tenant. * /* ww w.j a v a 2 s. co m*/ * @param tenantId * @param tenantDB */ public void deleteMemberRecords(String tenantId, String tenantDB) { Connection conn = null; Statement stmt = null; final String DELETE_MEMBER_TABLE_RECORDS = "DELETE FROM Member WHERE TenantId='" + tenantId + "'"; int index = url.indexOf("="); String connUrl = url.substring(0, index + 1) + PRIMARY_DB + ";"; try { //JDBC driver Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); //Open connection conn = DriverManager.getConnection(connUrl, username, password); //Query Execution stmt = conn.createStatement(); stmt.executeUpdate(DELETE_MEMBER_TABLE_RECORDS); } catch (SQLException se) { se.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } finally { closeStatement(stmt); closeConnection(conn); } //end try }
From source file:com.persistent.cloudninja.utils.TenantProfileUtility.java
/** * Close Statement/* w w w . jav a 2s .c o m*/ */ public void closeStatement(Statement statement) { if (statement != null) { try { statement.close(); } catch (SQLException sqlException) { sqlException.printStackTrace(); } } }
From source file:com.persistent.cloudninja.utils.TenantProfileUtility.java
/** * Close Connection/* w w w.j av a 2 s . c o m*/ */ public void closeConnection(Connection connection) { if (connection != null) { try { connection.close(); } catch (SQLException sqlException) { sqlException.printStackTrace(); } } }
From source file:uk.ac.ebi.fgpt.lode.impl.JenaVirtuosoConnectionPoolService.java
public Graph getNamedGraph(String graphName) { virtuoso.jena.driver.VirtGraph set = null; DataSource source = null;//from w w w .ja v a2s .c o m try { source = datasourceProvider.getDataSource(); VirtGraph g; if (graphName != null) { g = new VirtGraph(graphName, source); } else { g = new VirtGraph(source); } g.setQueryTimeout(getVirtuosoQueryTimeout()); g.setReadFromAllGraphs(isVirtuosoAllGraphs()); return g; } catch (SQLException e) { e.printStackTrace(); } throw new RuntimeException("Can't create Virtuoso graph from datasource"); }
From source file:com.persistent.cloudninja.utils.TenantProfileUtility.java
/** * Drops the tenant database./*ww w . jav a 2 s. c o m*/ * * @param tenantDB */ public void deleteTenant(String tenantDB) { Connection conn = null; Statement stmt = null; final String DROP_TENANT = "DROP DATABASE " + tenantDB; int index = url.indexOf("="); String connUrl = url.substring(0, index + 1) + MASTER_DB + ";"; try { //JDBC driver Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); //Open connection conn = DriverManager.getConnection(connUrl, username, password); //Query Execution stmt = conn.createStatement(); stmt.executeUpdate(DROP_TENANT); } catch (SQLException se) { se.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } finally { closeStatement(stmt); closeConnection(conn); } }
From source file:json.JobController.java
@RequestMapping(value = "/getAllJobs", method = RequestMethod.GET, produces = "application/json") public @ResponseBody ArrayList<Jobs> getAllJobs() { Connection conn = null;//from w w w. j av a 2 s . c o m Statement stmt = null; ResultSet rs = null; ArrayList<Jobs> jobList = new ArrayList(); try { //Set up connection with database conn = ConnectionManager.getConnection(); stmt = conn.createStatement(); //Execute sql satatement to obtain jobs from database rs = stmt.executeQuery("select * from job ORDER BY jobID desc;"); while (rs != null && rs.next()) { int jobID = rs.getInt(1); String postingTitle = rs.getString(2); String businessUnit = rs.getString(3); String location = rs.getString(4); String createdBy = rs.getString(5); String createdOn = rs.getString(6); String employmentType = rs.getString(8); String shift = rs.getString(9); String description = rs.getString(10); String requirement = rs.getString(11); String validity = rs.getString(12); Jobs jobPost = new Jobs(jobID, businessUnit, postingTitle, createdBy, createdOn, location, employmentType, shift, description, requirement, validity); jobList.add(jobPost); } } catch (SQLException ex) { ex.printStackTrace(); } finally { ConnectionManager.close(conn, stmt, rs); } return jobList; }
From source file:it.itis.pertini.falessi.tunes.services.AbstractService.java
protected final Response insertOrUpdate(String queryId, Object... params) { try {/* w w w.j a v a 2 s .com*/ int updated = queryRunner.update(getQuery(queryId), params); Status status; if (updated != 0) { status = Status.CREATED; } else { status = Status.NOT_FOUND; } return Response.status(status).build(); } catch (SQLException e) { e.printStackTrace(); throw new WebApplicationException(new ResponseBuilderImpl().entity(toErrorMessage(e)) .status(Response.Status.INTERNAL_SERVER_ERROR).build()); } }
From source file:com.api.dao.user.SqlUserDao.java
@Override public Collection<User> findAll() throws SQLException { User user;//from www . j a v a 2 s . c o m List<User> users = new ArrayList<>(); Connection connection = dataSource.getConnection(); String findAllQuery = environment.getRequiredProperty(FIND_ALL); try (Statement stmt = connection.createStatement()) { ResultSet rs = stmt.executeQuery(findAllQuery); while (rs.next()) { user = new User(); String firstName = rs.getString("firstName"); String lastName = rs.getString("lastName"); String email = rs.getString("email"); int dbid = rs.getInt("id"); user.setFirstName(firstName); user.setLastName(lastName); user.setId(dbid); user.setEmail(email); users.add(user); } } catch (SQLException sqle) { sqle.printStackTrace(); throw sqle; } return users; }
From source file:corner.migration.impl.DBMigrationInitializerTest.java
private void executeSchemaStatement(Statement stmt, String sql) throws SQLException { try {/*w ww . j av a 2 s. com*/ stmt.executeUpdate(sql); } catch (SQLException ex) { ex.printStackTrace(); } }