>i use prepared statements extensively with instantdb. i'd want to see more
>of the code with the actual declaration of prepared statement.
>
>they will work.
Hi, so, here they are,
Real thanks for checking that.
Currently making it into an app for my tests (this a method found in the current servlet).
Paul
public void performInsert(String tableName,
String[0 colNames, String[] colContents)
{
StringBuffer buff = new StringBuffer();
buff.append("INSERT INTO ");
buff.append(tableName);
buff.append(" (");
// prepare a prepared statement
int numCol = 0;
for( int i=0; i<colNames.length; i++) {
if (i > 0 ) buff.append(",");
buff.append(colNames[i]);
}
buff.append(") VALUES (");
for(int i=0; i< colContents.length; i++) {
if ( i>0) buff.append(",?");
else buff.append("?)");
}
System.out.println("Executing prepared statement : " + buff.toString());
// send commands
try {
java.sql.PreparedStatement stmt =
connection.prepareStatement(buff.toString());
int i=0;
for(int i=0; i< colContents.length; i++) {
stmt.setString(colContents.toString());
}
stmt.execute();
stmt.close();
}
-----------------------------------------------------------------------------
To unsubscribe from this mailing list, send email to majordomo@enhydra.org
with the text "unsubscribe instantdb" in the body of the email.
If you have other questions regarding this mailing list, send email to
the list admin at owner-instantdb@enhydra.org.
|