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


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