c0.createStatement().executeUpdate("create table australia (ID INTEGER NOT NULL, Name VARCHAR(100), FirstName VARCHAR(100), Points INTEGER, LicenseID INTEGER, PRIMARY KEY(ID))");
c0.createStatement().executeUpdate("create table australia (ID INTEGER NOT NULL, Name VARCHAR(100), FirstName VARCHAR(100), Points INTEGER, LicenseID INTEGER, PRIMARY KEY(ID))");
stat.execute("CREATE INDEX IDXNAME ON TEST(NAME)");
stat.execute("INSERT INTO TEST VALUES(0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)");
stat.execute("INSERT INTO TEST VALUES(1, 'Hello', -1, 10.30, '2001-02-03 11:22:33.4455', X'FF0102', TRUE, 3000, 1234567890123456789, X'1122AA', DATE '0002-01-01', TIME '00:00:00', 'J\u00fcrg', 2.25)");
testRow(stat,"TEST");
stat.execute("INSERT INTO TEST VALUES(2, 'World', 30, 100.05, '2005-12-31 12:34:56.789', X'FFEECC33', FALSE, 1, -1234567890123456789, X'4455FF', DATE '9999-12-31', TIME '23:59:59', 'George', -2.5)");
* Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
packageorg.h2.test.db;
importjava.io.ByteArrayInputStream;
importjava.io.CharArrayReader;
importjava.io.InputStream;
importjava.io.Reader;
importjava.io.StringReader;
importjava.sql.Blob;
importjava.sql.Clob;
importjava.sql.Connection;
importjava.sql.DatabaseMetaData;
importjava.sql.PreparedStatement;
importjava.sql.ResultSet;
importjava.sql.Statement;
importjava.util.Random;
importorg.h2.test.TestBase;
importorg.h2.util.IOUtils;
importorg.h2.util.StringUtils;
/**
* @author Thomas
*/
publicclassTestLobextendsTestBase{
publicvoidtest()throwsException{
if(config.memory){
return;
}
testLobCopy();
testLobHibernate();
testLobCopy(false);
testLobCopy(true);
testLobCompression(false);
testLobCompression(true);
testManyLobs();
testClob();
testUpdateLob();
testLobReconnect();
testLob(false);
testLob(true);
testJavaObject();
}
privatevoidtestLobCopy()throwsException{
deleteDb("lob");
Connectionconn=reconnect(null);
Statementstat=conn.createStatement();
stat.execute("create table test(id int, data clob)");
stat.execute("insert into test values(1, space(1000));");
stat.execute("insert into test values(2, space(1000));");
stat.execute("create table test2(id int, data clob);");
stat.execute("insert into test2 select * from test;");
stat.execute("drop table test;");
stat.execute("select * from test2;");
stat.execute("update test2 set id=id;");
stat.execute("select * from test2;");
conn.close();
}
privatevoidtestLobHibernate()throwsException{
deleteDb("lob");
Connectionconn0=reconnect(null);
conn0.getAutoCommit();
conn0.setAutoCommit(false);
DatabaseMetaDatadbMeta0=
conn0.getMetaData();
dbMeta0.getDatabaseProductName();
dbMeta0.getDatabaseMajorVersion();
dbMeta0.getDatabaseProductVersion();
dbMeta0.getDriverName();
dbMeta0.getDriverVersion();
dbMeta0.supportsResultSetType(1004);
dbMeta0.supportsBatchUpdates();
dbMeta0.dataDefinitionCausesTransactionCommit();
dbMeta0.dataDefinitionIgnoredInTransactions();
dbMeta0.supportsGetGeneratedKeys();
conn0.getAutoCommit();
conn0.getAutoCommit();
conn0.commit();
conn0.setAutoCommit(true);
Statementstat0=
conn0.createStatement();
stat0.executeUpdate("drop table CLOB_ENTITY if exists");
stat0.getWarnings();
stat0.executeUpdate("create table CLOB_ENTITY (ID bigint not null, SER_DATA clob, CLOB_DATA clob, primary key (ID))");
stat0.getWarnings();
stat0.close();
conn0.getWarnings();
conn0.clearWarnings();
conn0.setAutoCommit(false);
conn0.getAutoCommit();
conn0.getAutoCommit();
PreparedStatementprep0=
conn0.prepareStatement("select max(ID) from CLOB_ENTITY");
ResultSetrs0=
prep0.executeQuery();
rs0.next();
rs0.getLong(1);
rs0.wasNull();
rs0.close();
prep0.close();
conn0.getAutoCommit();
PreparedStatementprep1=
conn0.prepareStatement("insert into CLOB_ENTITY (SER_DATA, CLOB_DATA, ID) values (?, ?, ?)");
prep1.setNull(1,2005);
StringBufferbuff=newStringBuffer(10000);
for(inti=0;i<10000;i++){
buff.append((char)('0'+(i%10)));
}
Readerx=newStringReader(buff.toString());
prep1.setCharacterStream(2,x,10000);
prep1.setLong(3,1);
prep1.addBatch();
prep1.executeBatch();
prep1.close();
conn0.getAutoCommit();
conn0.getAutoCommit();
conn0.commit();
conn0.isClosed();
conn0.getWarnings();
conn0.clearWarnings();
conn0.getAutoCommit();
conn0.getAutoCommit();
PreparedStatementprep2=
conn0.prepareStatement("select clobholdin0_.ID as ID0_0_, clobholdin0_.SER_DATA as SER2_0_0_, clobholdin0_.CLOB_DATA as CLOB3_0_0_ from CLOB_ENTITY clobholdin0_ where clobholdin0_.ID=?");