List of usage examples for java.sql ResultSet getDate
java.sql.Date getDate(String columnLabel) throws SQLException;
ResultSet
object as a java.sql.Date
object in the Java programming language. From source file:com.ewcms.component.rss.dao.RssDAO.java
public List<Item> findItemByChannel(Integer id, Integer row) { String sql = "Select t2.title,t2.url,t2.summary,t2.published From content_article_main t1,content_article t2 " + " Where t1.article_id = t2.id And t1.channel_id = ? " + " And t2.published < now() And t2.status='RELEASE' " + " Order By t2.published Desc Limit ? "; return jdbcTemplate.query(sql, new Object[] { id, row }, new RowMapper<Item>() { @Override/* w ww. ja v a2 s . co m*/ public Item mapRow(ResultSet rs, int rowNum) throws SQLException { Item item = new Item(); item.setTitle(rs.getString("title")); item.setUrl(rs.getString("url")); item.setDescription(rs.getString("summary")); item.setPublished(rs.getDate("published")); return item; } }); }
From source file:edu.pitt.resumecore.Prescription.java
public Prescription(PatientVisit patientVisit, User patient) { db = new MySqlDbUtilities(); String sql = "SELECT * FROM emr.prescriptions JOIN emr.prescription_medications " + "ON prescriptionId=fk_prescriptionId " + "JOIN emr.medications ON medId=fk_medicationId "; sql += "WHERE patientVisitId = '" + patientVisit.getExamID() + "' AND patientId = '" + patient.getUserID() + "';"; try {/*from w ww. j a va 2 s .c o m*/ ResultSet rs = db.getResultSet(sql); if (rs.next()) { this.prescriptionId = rs.getString("prescriptionId"); this.prescriptionDate = rs.getDate("prescriptionDate"); this.expires = rs.getDate("expires"); this.patientVisit = patientVisit; //new PatientVisit(rs.getString("patientVisitId")); this.patient = patient; //new User(rs.getString("patientId")); Medication med = new Medication(rs.getString("medId")); this.getMedicationList().add(med); } } catch (SQLException ex) { ErrorLogger.log( "An error had occured in Prescription(PatientVisit patientVisit, User patient) constructor of Medication class" + ex.getMessage()); ErrorLogger.log(sql); } finally { db.closeDbConnection(); } }
From source file:iddb.web.security.dao.SessionDAO.java
/** * @param session/*ww w. j a va 2s. c o m*/ * @param rs * @throws SQLException */ private void loadSession(Session session, ResultSet rs) throws SQLException { session.setKey(rs.getString("id")); session.setUserId(rs.getLong("userid")); session.setIp(rs.getString("ip")); session.setCreated(rs.getDate("created")); }
From source file:com.apress.prospringintegration.springenterprise.stocks.dao.jdbc.JdbcTemplateStockDao.java
@Override public List<Stock> findAvailableStockBySymbol(String symbol) { String sql = " SELECT * from STOCKS" + " WHERE SYMBOL = ? order by PRICE_PER_SHARE"; List<Stock> ret = jdbcTemplate.query(sql, new Object[] { symbol }, new RowMapper<Stock>() { public Stock mapRow(ResultSet rs, int rowNum) throws SQLException { Stock s = new Stock(rs.getString("SYMBOL"), rs.getString("INVENTORY_CODE"), rs.getString("EXCHANGE_ID"), rs.getFloat("PRICE_PER_SHARE"), rs.getInt("QUANTITY_AVAILABLE"), rs.getDate("PURCHASE_DATE")); return s; }/* w w w.j a v a 2s . co m*/ }); return ret; }
From source file:br.gov.jfrj.siga.gc.gsa.GcInformacaoAdaptor.java
public Date getSysdate() { Date currentDate = null;/*from w w w . ja va 2s. c o m*/ Connection conn = null; Statement stmt = null; String query = "SELECT SYSDATE FROM DUAL"; try { conn = getConnection(); stmt = conn.createStatement(); // Execute a SELECT query on Oracle Dummy DUAL Table. Useful for // retrieving system values // Enables us to retrieve values as if querying from a table ResultSet rs = stmt.executeQuery(query); if (rs.next()) { currentDate = rs.getDate(1); // get first column returned System.out.println("Current Date from Oracle is : " + currentDate); } rs.close(); } catch (Exception ex) { throw new RuntimeException(ex); } finally { if (stmt != null) { try { stmt.close(); } catch (SQLException e) { e.printStackTrace(); } } if (conn != null) { try { conn.close(); } catch (SQLException e) { e.printStackTrace(); } } } return currentDate; }
From source file:com.abixen.platform.service.businessintelligence.multivisualisation.application.service.database.AbstractDatabaseService.java
private DataValueDto getValueAsDataSourceValueDateWeb(ResultSet row, String columnName) throws SQLException { Date value = row.getDate(row.findColumn(columnName)); return new DataValueDto<Date>().setValue(value); }
From source file:dao.CircleDAO.java
public Posts setPostData(Posts post) { String query =/*w w w.jav a 2 s. c o m*/ "SELECT a.UserId, b.* " + "\nFROM writes a, post b " + "\nWHERE a.PostId = " + post.getPostID() + " AND b.PostId = " + post.getPostID(); Posts post2 = this.jdbcTemplate.queryForObject(query, new RowMapper<Posts>() { @Override public Posts mapRow(ResultSet rs, int rowNum) throws SQLException { Posts posts = new Posts(); posts.setAuthor(rs.getInt("UserId")); posts.setDate(rs.getDate("Date").toString()); posts.setContent(rs.getString("Content")); return posts; } }); post.setPosterName(getName(post2.getAuthor())); post.setAuthor(post2.getAuthor()); post.setDate(post2.getDate()); post.setContent(post2.getContent()); return post; }
From source file:AllEmployeesServlet.java
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println("<html>"); out.println("<head><title>All Employees</title></head>"); out.println("<body>"); out.println("<center><h1>All Employees</h1>"); Connection conn = null;// w w w .j a v a2 s.com Statement stmt = null; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); conn = DriverManager.getConnection("jdbc:odbc:Employees"); stmt = conn.createStatement(); String orderBy = request.getParameter("sort"); if ((orderBy == null) || orderBy.equals("")) { orderBy = "SSN"; } String orderByDir = request.getParameter("sortdir"); if ((orderByDir == null) || orderByDir.equals("")) { orderByDir = "asc"; } String query = "SELECT Employees.SSN, Employees.Name, " + "Employees.Salary, " + "Employees.Hiredate, Location.Location " + "FROM Location " + "INNER JOIN Employees " + "ON Location.Loc_Id = Employees.Loc_Id " + "ORDER BY " + orderBy + " " + orderByDir + ";"; ResultSet rs = stmt.executeQuery(query); while (rs.next()) { long employeeSSN = rs.getLong("SSN"); String employeeName = rs.getString("Name"); long employeeSalary = rs.getLong("Salary"); Date employeeHiredate = rs.getDate("Hiredate"); String employeeLocation = rs.getString("Location"); out.print(employeeSSN + "::"); out.print(employeeName + "::"); out.print(employeeSalary + "::"); out.print(employeeHiredate + "::"); out.print(employeeLocation + "::"); } } catch (SQLException e) { out.println("An error occured while retrieving " + "all employees: " + e.toString()); } catch (ClassNotFoundException e) { throw (new ServletException(e.toString())); } finally { try { if (stmt != null) { stmt.close(); } if (conn != null) { conn.close(); } } catch (SQLException ex) { } } out.println("</center>"); out.println("</body>"); out.println("</html>"); out.close(); }
From source file:com.persistent.cloudninja.mapper.ProvisioningLogRowMapper.java
@Override public ProvisioningLogEntity mapRow(ResultSet rs, int rownum) throws SQLException { ProvisioningLogEntity provisioningLogEntity = new ProvisioningLogEntity(); provisioningLogEntity.setTenantId(rs.getString("TenantId")); provisioningLogEntity.setTask(rs.getString("Task")); provisioningLogEntity.setMessage(rs.getString("Message")); provisioningLogEntity.setCreated(rs.getDate("Created")); return provisioningLogEntity; }