2 messages in com.mysql.lists.javaInserts and Result Sets
FromSent OnAttachments
mike markovich19 Nov 2002 14:27 
Sean Hager20 Nov 2002 08:04 
Subject:Inserts and Result Sets
From:mike markovich (mike@amyskitchen.net)
Date:11/19/2002 02:27:37 PM
List:com.mysql.lists.java

Hi Everyone,

I use the java method below to performs inserts to a mysql database. The method
works great now, but I am concerned about what will happen when it is moved from
a test environment to a production environment. I am concerned that the
executeQuery(query) statement will take a long time when the table it is
accessing contains thousands of records. Any thoughts?

Many Thanks, Mike

public void insert(Row row, Table table) throws SQLException {

Column column;

Statement stmt = table.getConnection().createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);

String query = "SELECT * FROM " + table.getTableName();

ResultSet rs = stmt.executeQuery(query); Iterator iter = row.getColumnIterator(); rs.moveToInsertRow();

while (iter.hasNext()) { column = (Column) iter.next(); rs.updateObject(column.getColumnName(), column.getColumnValue()); }

rs.insertRow();

}