File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
OCA Java SE 8 Programmer I Study Guide 1Z0-808
this week in the
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?
Did you see how Paul
cut 87% off of his electric heat bill with 82 watts of micro heaters
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