InstantDB Project
About InstantDB
Project Mail Lists
Short History
Reporting Bugs
Screen Shots
3rd Party Examples
FAQs

Software
Downloads
Documentation
CVS Repositories
Roadmap
License

About Enhydra.org
Who We Are
News, Articles & Events
Getting Involved
Contact Us

Community
Demos
Contributions
Resources
Case Studies
On The Edge! -NEW-
Commercial Vendors


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: InstantDB: About prepared statements


Paul,

there is a bug in the code you send, if this is the original code may be
this has cause it. see inline comment:

-Arno

> 	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());

should be: stmt.setString(colContents[i].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.

-----------------------------------------------------------------------------
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.