From: | "Dax Duskin" <dax(dot)duskin(at)zsassociates(dot)com> |
---|---|
To: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: Attribute 'tablecolumn' not found and converting current.timestamp to current.date |
Date: | 2001-03-08 15:05:56 |
Message-ID: | 86256A09.00530C3E.00@zsserver3.zsassociates.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
did you try out your sql statement in the psql command line? That would be a
good place to start.
I recommend the following:
"select Id, Titel, Description, FromDate, ToDate from tablename, current where
tablename.FromDate <=current.timestamp and tablename.ToDate >=current.timestamp"
Dax Duskin
Poul Kristensen <bcc5226(at)vip(dot)cybercity(dot)dk> on 03/08/2001 08:43:01 AM
To: pgsql-novice(at)postgresql(dot)org
cc: (bcc: Dax Duskin/Evanston/ZSAssociates)
Subject: [NOVICE] Attribute 'tablecolumn' not found and converting
current.timestamp to current.date
Hi there,
I don't know if this is the right list but I don't know whereelse to
ask.
I'm a very novice getting table data from PG 7.0.2 using java.
I have this sql statement
"select Id, Titel, Description, FromDate, ToDate from tablename where
FromDate <=current.timestamp and ToDate >=current.timestamp"
the FromDate and the ToDate are timestamp fields.
and get the following error => attribute "Id" not found.
I understand that PG is case sensitive.
Next problem:
Is it possible to convert/ format the selected timestamp field to a
date format within the
sqlstatement or should it be done in java?
Could you give me a hint of how to do this?
TIA
Poul
Here is the program - sorry if some syntaxsproblem - I had troubles
copyind into Netscape.
import java.io.*;
import java.util.Enumeration;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import java.net.*;
public class
testservlet extends HttpServlet{ Connection theConnection; private
ServletConfig config;
public void init(ServletConfig config) throws
ServletException{ this.config=config; }
public void service (HttpServletRequest req, HttpServletResponse res)
throws ServletException,
IOException {
HttpSession session = req.getSession(true);
res.setContentType("text/html");
PrintWriter out = res.getWriter();
out.println("");
out.println("");
out.println("");
out.println("List");
out.println("");
out.println("");
out.println("");
out.println("");
out.println("");
out.println("");
try{
//Loading Sun's JDBC ODBC Driver
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//Class.forName("postgresql.Driver");
//Connect to db Data source theConnection =
DriverManager.getConnection("jdbc:odbc:pg");
Statement
theStatement=theConnection.createStatement();
ResultSet
theResult=theStatement.executeQuery("select Id, Titel, Description,
FromDate,ToDate from tablename where OnlineFra <= current.timestamp and
OnlineTil >= current.timestamp");
//Select all records
//Fetch all the records and print in table
while(theResult.next()){
out.println();
out.println("some html");
out.println("");
out.println("");
out.println("");
String s=theResult.getString(5);
out.println("");
out.println(""); }
theResult.close();
//Close the result
set theStatement.close();
//Close statement theConnection.close();
//Close database Connection }
catch(Exception e){
out.println(e.getMessage());
//Print trapped error. }
out.println("some html
column1
column2
column3
" + theResult.getString(2) + "
" + theResult.getString(3) + "
" +
theResult.getString(4) + "
" + s + ">
"); out.println("
"); } public void destroy(){ } }
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org
Attachment | Content-Type | Size |
---|---|---|
att1.eml | application/octet-stream | 4.9 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2001-03-08 15:07:27 | Re: AOLServer/PHP/PostGres Site... |
Previous Message | Daniel A. Melo | 2001-03-08 14:53:52 | compilation error |