A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
JavaRanch
»
Java Forums
»
Databases
»
JDBC
Author
building a dynamic Query String
prabhu kandanur
Ranch Hand
Joined: Oct 18, 2003
Posts: 34
posted
Jul 09, 2004 00:43:00
0
hi
building a dynamic Query
String
"using
java
code examples"
where can i get
-prabhu
M. Gagnon
Ranch Hand
Joined: Feb 18, 2004
Posts: 68
posted
Jul 09, 2004 20:53:00
0
Could you perhaps mean a
PreparedStatement
? For example:
String query = "SELECT * FROM sometable WHERE sometable.somefield = ?";
PreparedStatement
stmt = conn.prepareStatement(query);
The question mark represents a value that is set at runtime. You set the value with a call to a setter method on the Statement object:
// Could be setInt(), setDate(), setBoolean(), etc.
stmt.setString( 1, getValueForSQL() );
rs = stmt.executeQuery();
I agree. Here's the link:
http://aspose.com/file-tools
subject: building a dynamic Query String
Similar Threads
Dynamically setting sort direction
Stored Procedure VS normal Query
Building Dynamic Query in JPA
Dynamic query creation
JPA Query using " where in" and setParameter
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter