A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
JavaRanch
»
Java Forums
»
Databases
»
JDBC
Author
PreparedStatement
Manuel Paco
Ranch Hand
Joined: Sep 23, 2001
Posts: 58
posted
Oct 17, 2001 09:48:00
0
Would you please tell what is wrong with my "String query" ? . DATEVALUE('?') does not seem to work.
DATEVALUE('2001-10-10') is a MS-Access function.
private Connection connection; private PreparedStatement pstmt; private ResultSet resultSet; .... private void getTable() { try { prepareSQLString("2001-10-15"); displayResultSet( resultSet ); } catch ( SQLException sqlex ) { sqlex.printStackTrace(); } } public void prepareSQLString(String stringDate) { String query = "SELECT * FROM addresses WHERE dateofinput = DATEVALUE('?') ORDER BY lastname"; try { pstmt = connection.prepareStatement(query); pstmt.setString(1, stringDate); resultSet = pstmt.executeQuery(); } catch (SQLException e) { System.out.println(e.toString()); } }
Jamie Robertson
Ranch Hand
Joined: Jul 09, 2001
Posts: 1879
I like...
posted
Oct 17, 2001 10:04:00
0
try losing the single quotes(not necessary with preparedStatements):
String query = "SELECT * FROM addresses WHERE dateofinput = DATEVALUE([B]?[/B]) ORDER BY lastname";
it worked for me.
Jamie
[This message has been edited by Jamie Robertson (edited October 17, 2001).]
Manuel Paco
Ranch Hand
Joined: Sep 23, 2001
Posts: 58
posted
Oct 17, 2001 21:59:00
0
Thanks Jamie.
I agree. Here's the link:
http://aspose.com/file-tools
subject: PreparedStatement
Similar Threads
How to read/write Blob images using Hibernate
How to display data from database to JSP Page in Struts2
Datasource Connection
howto modify database structure ?
Problem with preapred Statement
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter