Java + SQL inside XML

A

artmt

I have a SQL query inside XML document which is being read by JSP
application.
Is it possible to reference a Java method inside the SQL string?

Something that looks like this:

SELECT * FROM dual WHERE user = request.getRemoteUser()

If this is possible what is the correct syntax?

Thanks
-Art
 
R

Roedy Green

SELECT * FROM dual WHERE user = request.getRemoteUser()

If this is possible what is the correct syntax?

you create a prepared statement, then fill in the variables with
values gleaned from java calls.

// With PreparedStatement, you leave ? where you come back later to
fill in the data.
// Update vendortimestamp field if the new value is bigger.
// Demonstrates use of the GREATEST function.
PreparedStatement stmt = conn.prepareStatement( "UPDATE vendors SET
vendorTimestamp=GREATEST(vendorTimestamp, ?), WHERE vendorId=?" );
stmt.setLong( 1, aPossiblyBiggerTimestamp );
stmt.setInt( 2, desiredVendorId );
stmt.executeUpdate();
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,608
Members
45,248
Latest member
MagdalenaB

Latest Threads

Top