<tt><font size=2>JDBC connection using servlets</font></tt>
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Mathew_Vipin
Posted On:   Monday, October 1, 2001 02:31 AM

The general escape syntax for standard SQL date columns is: {d 'yyyy-mm-dd'} For literals: String sSQL = "SELECT colName FROM aTable " + "WHERE colDate = {d '2001-10- 21'}" For variables ( note that toString() is implicitly called on the date variable ): java.sql.Date jsqlDate; ... // set date String sSQL = "SELECT colName FROM aTable " + "WHERE colDate = {d '" + jsqlDate + "'}" i am using oracle 8.0 and not 8i and i can't get records using this   More>>

The general escape syntax for
standard SQL date columns is:

			
				
{d 'yyyy-mm-dd'}

For literals:

			
String sSQL =

"SELECT colName FROM aTable " +

"WHERE colDate = {d '2001-10-
21'}"



For variables ( note that toString() is
implicitly called on the date
variable ):

			

java.sql.Date jsqlDate;

... // set date

String sSQL =

"SELECT colName FROM aTable " +

"WHERE colDate = {d '" + jsqlDate + "'}"


i am using oracle 8.0 and not 8i
and i can't get records using this
query.
i have inserted
java.sql.date and accessing record
is not possible now. i tried with
java.sql.date as well as string.
The query is executing but no
records r selected. In oracle, date
field is seen as :
31-JAN-01
.
I tried the above format also which gives an exception
as:
invalid character
.
Pls. help me find
out the records on a specified date.
   <<Less

Re: <tt><font size=2>JDBC connection using servlets</font></tt>

Posted By:   Anonymous  
Posted On:   Friday, October 5, 2001 09:27 PM

The FAQ answer as quoted is the standard JDBC method and I can tell you that it certainly works on DB2. If it doesn't work for you, you need first to be absolutely sure that you are using a SQL date datatype in the database. If so, then check Oracle's site/documentation for bugs or DBMS specifics.

Re: <tt><font size=2>JDBC connection using servlets</font></tt>

Posted By:   Michael_Gaensler  
Posted On:   Monday, October 1, 2001 03:40 AM

Try to use the java.sql.PreparedStatement, which encapsulates the date formatting.
About | Sitemap | Contact