A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
JDBC and Relational Databases
java sql question
Joined: May 25, 2008
Nov 19, 2009 14:35:24
was reading through someones
code and i don't really understand the sql which is being constructed below :
insert into ...... values(?, ?, ?, %s, ?, %s, ?, ?, ? ....)
i know what the ? is for but what does the '%s' do ??
thanks in advance.
Joined: Dec 31, 2004
Nov 19, 2009 17:41:55
Perhaps the code you mention was used in a Formatter.
For instance I could write somewhat like this:
int salary = 100; String sql = "SELECT * FROM employee WHERE id = ? and salary >= %s"; String formattedSql = String.format(sql, salary); //would replace %s with the actual salary PreparedStatement stm = conn.prepareStatement(formattedSql) ...
Do you know if this is the case?
I agree. Here's the link:
subject: java sql question
Java mySql update statement
java/MYSQL Serious speed problem.
UML and PL/SQL
using more than one sql statements in a preparedstatement
how to get column information for a given sql string
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015