Following test case returns insert times of 80-130ms (on average
110ms). What am I doing wrong here? Why is the insert so slow? I'm
using the jdbc-nested-0.33.jar.

public class Test
{
    public static void main(String[] args)
    {
        Test test = new Test();
    }

    public Test()
    {
        try
        {
            Class.forName("org.sqlite.JDBC");

            Connection database =
DriverManager.getConnection("jdbc:sqlite:test.db");

            database.setAutoCommit(false);

            Statement statement = database.createStatement();
            statement.executeUpdate
            (
                "CREATE TABLE IF NOT EXISTS messages ("
                + "id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,"
                + "timestamp DATE NOT NULL,"
                + "data TEXT NOT NULL);"
            );

            statement.close();

            PreparedStatement preparedStatement =
database.prepareStatement
            (
                "INSERT INTO messages "
                + "(timestamp, data) VALUES (?, ?);"
            );
            preparedStatement.setDate(1, new Date(new
java.util.Date().getTime()));
            preparedStatement.setBytes(2, "<?xml version=\"1.0\"
encoding=UTF-8?><row>1</row>\r\n".getBytes());

            long debugStartTime = new java.util.Date().getTime();

            int result = preparedStatement.executeUpdate();
            database.commit();

            long debugEndTime = new java.util.Date().getTime();

            System.out.println("Insert time: " + (debugEndTime -
debugStartTime) + " ms");

            preparedStatement.close();

            database.close();
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }
}


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"SQLiteJDBC" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlitejdbc?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to