List of usage examples for java.sql Statement executeQuery
ResultSet executeQuery(String sql) throws SQLException;
ResultSet
object. From source file:com.porvak.bracket.social.database.upgrade.v3.UpdateEncryptionMethod.java
License:asdf
@Override protected void doExecuteStatement(Statement statement) throws SQLException { ResultSet rs = statement.executeQuery("select apiKey, secret from App"); while (rs.next()) { rs.updateString("apiKey", encrypt(decrypt(rs.getString("apiKey")))); rs.updateString("secret", encrypt(decrypt(rs.getString("secret")))); rs.updateRow();//from w w w. j a v a2s .c o m } rs = statement.executeQuery("select accessToken, secret from AppConnection"); while (rs.next()) { rs.updateString("accessToken", encrypt(decrypt(rs.getString("accessToken")))); rs.updateString("secret", encrypt(decrypt(rs.getString("secret")))); rs.updateRow(); } rs = statement.executeQuery("select member, provider, accessToken, secret from AccountConnection"); while (rs.next()) { rs.updateString("accessToken", encrypt(decrypt(rs.getString("accessToken")))); String secret = rs.getString("secret"); if (secret != null) { rs.updateString("secret", encrypt(decrypt(secret))); } rs.updateRow(); } }
From source file:ca.fastenalcompany.order.OrderManager.java
public void connect() { DBManager db = new DBManager(); Connection conn = null;// w ww .ja va2 s . co m try { conn = db.getMysqlConn(); String query = "select * from inventory"; Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(query); while (rs.next()) { for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) System.out.println(rs.getString(i)); } } catch (SQLException ex) { Logger.getLogger(FastenalCompany.class.getName()).log(Level.SEVERE, null, ex); } finally { try { if (conn != null) conn.close(); } catch (SQLException ex) { Logger.getLogger(FastenalCompany.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:controller.LoadImageServlet.java
/** * Handles the HTTP <code>GET</code> method. * * @param request servlet request/*from w w w . java 2s . com*/ * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String iid = request.getParameter("param1"); byte[] sImageBytes; try { Connection con = JdbcConnection.getConnection(); String Query = "SELECT image FROM user WHERE email ='" + iid + "';"; System.out.println("Query is" + Query); Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery(Query); System.out.println("..........1"); String name = "client_2"; if (rs.next()) { sImageBytes = rs.getBytes("image"); response.setContentType("image/jpeg"); response.setContentLength(sImageBytes.length); // Give the name of the image in the name variable in the below line response.setHeader("Content-Disposition", "inline; filename=\"" + name + "\""); BufferedInputStream input = new BufferedInputStream(new ByteArrayInputStream(sImageBytes)); BufferedOutputStream output = new BufferedOutputStream(response.getOutputStream()); byte[] buffer = new byte[8192]; int length; while ((length = input.read(buffer)) > 0) { output.write(buffer, 0, length); System.out.println(".......3"); } output.flush(); } } catch (Exception ex) { System.out.println("error :" + ex); } }
From source file:com.nilesh.GenericResourse.java
/** * PUT method for updating or creating an instance of GenericResourse * @param content representation for the resource * @return an HTTP response with content of the updated or created resource. *///from ww w . j a va 2s .co m @PUT @Path("/products") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public void putProduct(@QueryParam("id") int id, @QueryParam("name") String name, @QueryParam("description") String description, @QueryParam("quantity") int quantity) throws SQLException { Statement smt = conn.createStatement(); ResultSet rs = smt.executeQuery("update product set productid =" + id + ", name =" + name + ", description =" + description + ", quantity =" + quantity + " where productid =" + id); }
From source file:guru.bubl.module.neo4j_graph_manipulator.graph.graph.Neo4jWholeGraph.java
@Override public Set<VertexInSubGraphOperator> getAllVertices() { String query = String.format("START n=node:node_auto_index('%s:%s') RETURN n.uri as uri", Neo4jFriendlyResource.props.type, GraphElementType.vertex); Set<VertexInSubGraphOperator> vertices = new HashSet<>(); return NoExRun.wrap(() -> { Statement statement = connection.createStatement(); ResultSet rs = statement.executeQuery(query); while (rs.next()) { vertices.add(neo4jVertexFactory.withUri(URI.create(rs.getString("uri")))); }//from w ww.j av a 2 s . com return vertices; }).get(); }
From source file:guru.bubl.module.neo4j_graph_manipulator.graph.graph.Neo4jWholeGraph.java
@Override public Set<EdgeOperator> getAllEdges() { String query = String.format("START n=node:node_auto_index('%s:%s') RETURN n.uri as uri", Neo4jFriendlyResource.props.type, GraphElementType.edge); Set<EdgeOperator> edges = new HashSet<>(); return NoExRun.wrap(() -> { Statement statement = connection.createStatement(); ResultSet rs = statement.executeQuery(query); while (rs.next()) { edges.add(neo4jEdgeFactory.withUri(URI.create(rs.getString("uri")))); }/*from w ww .j a va 2 s . co m*/ return edges; }).get(); }
From source file:guru.bubl.module.neo4j_graph_manipulator.graph.graph.Neo4jWholeGraph.java
@Override public Set<SchemaOperator> getAllSchemas() { String query = String.format("START n=node:node_auto_index('%s:%s') RETURN n.%s as uri", Neo4jFriendlyResource.props.type, GraphElementType.schema, Neo4jFriendlyResource.props.uri); Set<SchemaOperator> schemas = new HashSet<>(); return NoExRun.wrap(() -> { Statement statement = connection.createStatement(); ResultSet rs = statement.executeQuery(query); while (rs.next()) { schemas.add(schemaFactory.withUri(URI.create(rs.getString("uri")))); }/*from w w w .j av a 2 s. co m*/ return schemas; }).get(); }
From source file:guru.bubl.module.neo4j_graph_manipulator.graph.graph.Neo4jWholeGraph.java
@Override public Set<GraphElementOperator> getAllGraphElements() { String query = String.format("START n=node:node_auto_index('( %s:%s) ') RETURN n.%s as uri", Neo4jFriendlyResource.props.type, StringUtils.join(GraphElementType.names(), " OR type:"), Neo4jFriendlyResource.props.uri); Set<GraphElementOperator> graphElements = new HashSet<>(); return NoExRun.wrap(() -> { Statement statement = connection.createStatement(); ResultSet rs = statement.executeQuery(query); while (rs.next()) { graphElements.add(graphElementFactory.withUri(URI.create(rs.getString("uri")))); }//from w w w. j a v a 2s .c o m return graphElements; }).get(); }
From source file:guru.bubl.module.neo4j_graph_manipulator.graph.graph.Neo4jWholeGraph.java
@Override public Set<IdentificationOperator> getAllIdentifications() { String query = String.format("START n=node:node_auto_index('( %s:%s) ') RETURN n.%s as uri", Neo4jFriendlyResource.props.type, StringUtils.join(IdentificationType.names(), " OR type:"), Neo4jFriendlyResource.props.uri); Set<IdentificationOperator> identifications = new HashSet<>(); return NoExRun.wrap(() -> { Statement statement = connection.createStatement(); ResultSet rs = statement.executeQuery(query); while (rs.next()) { identifications.add(identificationFactory.withUri(URI.create(rs.getString("uri")))); }/*from ww w . j ava2s .c o m*/ return identifications; }).get(); }