提交 b3836d31 authored 作者: Thomas Mueller's avatar Thomas Mueller

Limit line length to 80 characters

上级 fda7e2d5
......@@ -2312,7 +2312,8 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
private void checkColumnIndex(int columnIndex) throws SQLException {
if (columnIndex < 1 || columnIndex > columns.size()) {
throw DbException.getInvalidValueException("columnIndex", columnIndex).getSQLException();
throw DbException.getInvalidValueException(
"columnIndex", columnIndex).getSQLException();
}
}
......
......@@ -140,9 +140,10 @@ public abstract class TriggerAdapter implements Trigger {
* @throws SQLException if the operation must be undone
*/
@Override
public void fire(Connection conn, Object[] oldRow,
Object[] newRow) throws SQLException {
fire(conn, wrap(oldResultSet, oldSource, oldRow), wrap(newResultSet, newSource, newRow));
public void fire(Connection conn, Object[] oldRow, Object[] newRow)
throws SQLException {
fire(conn, wrap(oldResultSet, oldSource, oldRow),
wrap(newResultSet, newSource, newRow));
}
/**
......@@ -162,9 +163,11 @@ public abstract class TriggerAdapter implements Trigger {
* DELETE)
* @throws SQLException if the operation must be undone
*/
public abstract void fire(Connection conn, ResultSet oldRow, ResultSet newRow) throws SQLException;
public abstract void fire(Connection conn, ResultSet oldRow,
ResultSet newRow) throws SQLException;
private static SimpleResultSet wrap(SimpleResultSet rs, TriggerRowSource source, Object[] row) throws SQLException {
private static SimpleResultSet wrap(SimpleResultSet rs,
TriggerRowSource source, Object[] row) throws SQLException {
if (row == null) {
return null;
}
......
......@@ -45,7 +45,8 @@ public class DbUpgrade {
* @param info the properties
* @return the connection if connected with the old version (NO_UPGRADE)
*/
public static Connection connectOrUpgrade(String url, Properties info) throws SQLException {
public static Connection connectOrUpgrade(String url, Properties info)
throws SQLException {
if (!UPGRADE_CLASSES_PRESENT) {
return null;
}
......@@ -100,12 +101,15 @@ public class DbUpgrade {
DbUpgrade.deleteOldDb = deleteOldDb;
}
private static Connection connectWithOldVersion(String url, Properties info) throws SQLException {
url = "jdbc:h2v1_1:" + url.substring("jdbc:h2:".length()) + ";IGNORE_UNKNOWN_SETTINGS=TRUE";
private static Connection connectWithOldVersion(String url, Properties info)
throws SQLException {
url = "jdbc:h2v1_1:" + url.substring("jdbc:h2:".length()) +
";IGNORE_UNKNOWN_SETTINGS=TRUE";
return DriverManager.getConnection(url, info);
}
private static void upgrade(ConnectionInfo ci, Properties info) throws SQLException {
private static void upgrade(ConnectionInfo ci, Properties info)
throws SQLException {
String name = ci.getName();
String data = name + ".data.db";
String index = name + ".index.db";
......@@ -117,11 +121,13 @@ public class DbUpgrade {
try {
if (scriptInTempDir) {
new File(Utils.getProperty("java.io.tmpdir", ".")).mkdirs();
script = File.createTempFile("h2dbmigration", "backup.sql").getAbsolutePath();
script = File.createTempFile(
"h2dbmigration", "backup.sql").getAbsolutePath();
} else {
script = name + ".script.sql";
}
String oldUrl = "jdbc:h2v1_1:" + name + ";UNDO_LOG=0;LOG=0;LOCK_MODE=0";
String oldUrl = "jdbc:h2v1_1:" + name +
";UNDO_LOG=0;LOG=0;LOCK_MODE=0";
String cipher = ci.getProperty("CIPHER", null);
if (cipher != null) {
oldUrl += ";CIPHER=" + cipher;
......@@ -130,7 +136,8 @@ public class DbUpgrade {
Statement stat = conn.createStatement();
String uuid = UUID.randomUUID().toString();
if (cipher != null) {
stat.execute("script to '" + script + "' cipher aes password '" + uuid + "' --hide--");
stat.execute("script to '" + script +
"' cipher aes password '" + uuid + "' --hide--");
} else {
stat.execute("script to '" + script + "'");
}
......@@ -144,7 +151,8 @@ public class DbUpgrade {
conn = new JdbcConnection(ci, true);
stat = conn.createStatement();
if (cipher != null) {
stat.execute("runscript from '" + script + "' cipher aes password '" + uuid + "' --hide--");
stat.execute("runscript from '" + script +
"' cipher aes password '" + uuid + "' --hide--");
} else {
stat.execute("runscript from '" + script + "'");
}
......
......@@ -65,7 +65,8 @@ public class CacheLRU implements Cache {
* @param cacheSize the size
* @return the cache object
*/
public static Cache getCache(CacheWriter writer, String cacheType, int cacheSize) {
public static Cache getCache(CacheWriter writer, String cacheType,
int cacheSize) {
Map<Integer, CacheObject> secondLevel = null;
if (cacheType.startsWith("SOFT_")) {
secondLevel = new SoftHashMap<Integer, CacheObject>();
......@@ -121,7 +122,8 @@ public class CacheLRU implements Cache {
} else {
if (SysProperties.CHECK) {
if (old != rec) {
DbException.throwInternalError("old!=record pos:" + pos + " old:" + old + " new:" + rec);
DbException.throwInternalError("old!=record pos:" +
pos + " old:" + old + " new:" + rec);
}
}
if (!fifo) {
......@@ -170,7 +172,9 @@ public class CacheLRU implements Cache {
} else {
// can't remove any record, because the records can not be removed
// hopefully this does not happen frequently, but it can happen
writer.getTrace().info("cannot remove records, cache size too small? records:" + recordCount + " memory:" + memory);
writer.getTrace().info(
"cannot remove records, cache size too small? records:" +
recordCount + " memory:" + memory);
break;
}
}
......
......@@ -22,7 +22,8 @@ public class CacheTQ implements Cache {
private final Cache lru;
private final Cache fifo;
private final SmallLRUCache<Integer, Object> recentlyUsed = SmallLRUCache.newInstance(1024);
private final SmallLRUCache<Integer, Object> recentlyUsed =
SmallLRUCache.newInstance(1024);
private int lastUsed = -1;
private int maxMemory;
......
......@@ -45,7 +45,8 @@ public class CloseWatcher extends PhantomReference<Object> {
*/
private Closeable closeable;
public CloseWatcher(Object referent, ReferenceQueue<Object> q, Closeable closeable) {
public CloseWatcher(Object referent, ReferenceQueue<Object> q,
Closeable closeable) {
super(referent, q);
this.closeable = closeable;
}
......@@ -88,7 +89,8 @@ public class CloseWatcher extends PhantomReference<Object> {
* relatively slow)
* @return the close watcher
*/
public static CloseWatcher register(Object o, Closeable closeable, boolean stackTrace) {
public static CloseWatcher register(Object o, Closeable closeable,
boolean stackTrace) {
ReferenceQueue<Object> q = queue;
if (q == null) {
q = new ReferenceQueue<Object>();
......
......@@ -42,12 +42,14 @@ public class DateTimeUtils {
private static final int SHIFT_YEAR = 9;
private static final int SHIFT_MONTH = 5;
private static final int[] NORMAL_DAYS_PER_MONTH = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
private static final int[] NORMAL_DAYS_PER_MONTH = { 0, 31, 28, 31, 30, 31,
30, 31, 31, 30, 31, 30, 31 };
/**
* Offsets of month within a year, starting with March, April,...
*/
private static final int[] DAYS_OFFSET = { 0, 31, 61, 92, 122, 153, 184, 214, 245, 275, 306, 337, 366 };
private static final int[] DAYS_OFFSET = { 0, 31, 61, 92, 122, 153, 184,
214, 245, 275, 306, 337, 366 };
private static int zoneOffset;
private static Calendar cachedCalendar;
......@@ -341,7 +343,8 @@ public class DateTimeUtils {
* @param millis the number of milliseconds
* @return the number of milliseconds (UTC)
*/
public static long getMillis(TimeZone tz, int year, int month, int day, int hour, int minute, int second, int millis) {
public static long getMillis(TimeZone tz, int year, int month, int day,
int hour, int minute, int second, int millis) {
try {
return getTimeTry(false, tz, year, month, day, hour, minute, second, millis);
} catch (IllegalArgumentException e) {
......@@ -391,8 +394,8 @@ public class DateTimeUtils {
}
}
private static void setCalendarFields(Calendar cal, int year, int month, int day,
int hour, int minute, int second, int millis) {
private static void setCalendarFields(Calendar cal, int year, int month,
int day, int hour, int minute, int second, int millis) {
if (year <= 0) {
cal.set(Calendar.ERA, GregorianCalendar.BC);
cal.set(Calendar.YEAR, 1 - year);
......@@ -539,7 +542,8 @@ public class DateTimeUtils {
* @param timeZone the timezone
* @return the formatted date
*/
public static String formatDateTime(java.util.Date date, String format, String locale, String timeZone) {
public static String formatDateTime(java.util.Date date, String format,
String locale, String timeZone) {
SimpleDateFormat dateFormat = getDateFormat(format, locale, timeZone);
synchronized (dateFormat) {
return dateFormat.format(date);
......@@ -555,7 +559,8 @@ public class DateTimeUtils {
* @param timeZone the timeZone
* @return the parsed date
*/
public static java.util.Date parseDateTime(String date, String format, String locale, String timeZone) {
public static java.util.Date parseDateTime(String date, String format,
String locale, String timeZone) {
SimpleDateFormat dateFormat = getDateFormat(format, locale, timeZone);
try {
synchronized (dateFormat) {
......@@ -567,7 +572,8 @@ public class DateTimeUtils {
}
}
private static SimpleDateFormat getDateFormat(String format, String locale, String timeZone) {
private static SimpleDateFormat getDateFormat(String format, String locale,
String timeZone) {
try {
// currently, a new instance is create for each call
// however, could cache the last few instances
......@@ -583,7 +589,8 @@ public class DateTimeUtils {
}
return df;
} catch (Exception e) {
throw DbException.get(ErrorCode.PARSE_ERROR_1, e, format + "/" + locale + "/" + timeZone);
throw DbException.get(ErrorCode.PARSE_ERROR_1, e,
format + "/" + locale + "/" + timeZone);
}
}
......@@ -641,7 +648,8 @@ public class DateTimeUtils {
* @param nanos the nanoseconds since midnight
* @return the timestamp
*/
public static Timestamp convertDateValueToTimestamp(long dateValue, long nanos) {
public static Timestamp convertDateValueToTimestamp(long dateValue,
long nanos) {
long millis = nanos / 1000000;
nanos -= millis * 1000000;
long s = millis / 1000;
......@@ -800,7 +808,8 @@ public class DateTimeUtils {
nanos -= d * NANOS_PER_DAY;
absoluteDay += d;
}
return ValueTimestamp.fromDateValueAndNanos(dateValueFromAbsoluteDay(absoluteDay), nanos);
return ValueTimestamp.fromDateValueAndNanos(
dateValueFromAbsoluteDay(absoluteDay), nanos);
}
/**
......
......@@ -27,10 +27,18 @@ public class DbDriverActivator implements BundleActivator {
public void start(BundleContext bundleContext) {
org.h2.Driver driver = org.h2.Driver.load();
Properties properties = new Properties();
properties.put(DataSourceFactory.OSGI_JDBC_DRIVER_CLASS, org.h2.Driver.class.getName());
properties.put(DataSourceFactory.OSGI_JDBC_DRIVER_NAME, "H2 JDBC Driver");
properties.put(DataSourceFactory.OSGI_JDBC_DRIVER_VERSION, Constants.getFullVersion());
bundleContext.registerService(DataSourceFactory.class.getName(), new OsgiDataSourceFactory(driver), properties);
properties.put(
DataSourceFactory.OSGI_JDBC_DRIVER_CLASS,
org.h2.Driver.class.getName());
properties.put(
DataSourceFactory.OSGI_JDBC_DRIVER_NAME,
"H2 JDBC Driver");
properties.put(
DataSourceFactory.OSGI_JDBC_DRIVER_VERSION,
Constants.getFullVersion());
bundleContext.registerService(
DataSourceFactory.class.getName(),
new OsgiDataSourceFactory(driver), properties);
}
/**
......
......@@ -52,7 +52,8 @@ public class SourceCompiler {
private static final Class<?> JAVAC_SUN;
private static final String COMPILE_DIR = Utils.getProperty("java.io.tmpdir", ".");
private static final String COMPILE_DIR =
Utils.getProperty("java.io.tmpdir", ".");
/**
* The class name to source code map.
......
......@@ -23,7 +23,8 @@ import org.h2.util.New;
* runtime of the tested application.
*/
public class Coverage {
private static final String IMPORT = "import " + Coverage.class.getPackage().getName() + ".Profile";
private static final String IMPORT = "import " +
Coverage.class.getPackage().getName() + ".Profile";
private final ArrayList<String> files = New.arrayList();
private final ArrayList<String> exclude = New.arrayList();
private Tokenizer tokenizer;
......@@ -41,15 +42,22 @@ public class Coverage {
private boolean perFunction = true;
private void printUsage() {
System.out.println("Usage:\n" + "- copy all your source files to another directory\n"
+ " (be careful, they will be modified - don't take originals!)\n" + "- java " + getClass().getName()
+ " <directory>\n" + " this will modified the source code and create 'profile.txt'\n"
+ "- compile the modified source files\n" + "- run your main application\n"
+ "- after the application exits, a file 'notCovered.txt' is created,\n"
+ " which contains the class names, function names and line numbers\n"
+ " of code that has not been covered\n\n" + "Options:\n" + "-r recurse all subdirectories\n"
+ "-e exclude files\n" + "-c coverage on a per-class basis\n"
+ "-f coverage on a per-function basis\n" + "<dir> directory name (. for current directory)");
System.out
.println("Usage:\n" +
"- copy all your source files to another directory\n" +
" (be careful, they will be modified - don't take originals!)\n" +
"- java " + getClass().getName() + " <directory>\n" +
" this will modified the source code and create 'profile.txt'\n" +
"- compile the modified source files\n" +
"- run your main application\n" +
"- after the application exits, a file 'notCovered.txt' is created,\n" +
" which contains the class names, function names and line numbers\n" +
" of code that has not been covered\n\n" +
"Options:\n" + "-r recurse all subdirectories\n" +
"-e exclude files\n" +
"-c coverage on a per-class basis\n" +
"-f coverage on a per-function basis\n" +
"<dir> directory name (. for current directory)");
}
/**
......@@ -124,7 +132,8 @@ public class Coverage {
for (int i = 0; i < len; i++) {
long t2 = System.currentTimeMillis();
if (t2 - time > 1000 || i >= len - 1) {
System.out.println((i + 1) + " of " + len + " " + (100 * i / len) + "%");
System.out.println((i + 1) + " of " + len +
" " + (100 * i / len) + "%");
time = t2;
}
String fileName = files.get(i);
......@@ -149,7 +158,9 @@ public class Coverage {
}
file = file.substring(0, i) + "." + file.substring(i + 1);
}
if (name.endsWith("Coverage.java") || name.endsWith("Tokenizer.java") || name.endsWith("Profile.java")) {
if (name.endsWith("Coverage.java") ||
name.endsWith("Tokenizer.java") ||
name.endsWith("Profile.java")) {
return;
}
File f = new File(name);
......@@ -359,7 +370,8 @@ public class Coverage {
private void processStatement() throws IOException {
while (true) {
if (token.equals("while") || token.equals("for") || token.equals("synchronized")) {
if (token.equals("while") || token.equals("for") ||
token.equals("synchronized")) {
read();
readThis("(");
processBracket();
......
......@@ -155,8 +155,9 @@ public class Profile extends Thread {
}
}
int percent = 100 * unvisited / maxIndex;
print("Not covered: " + percent + " % " + " (" + unvisited + " of " + maxIndex + "; throw="
+ unvisitedThrow + ")");
print("Not covered: " + percent + " % " + " (" +
unvisited + " of " + maxIndex + "; throw=" +
unvisitedThrow + ")");
} finally {
IOUtils.closeSilently(writer);
IOUtils.closeSilently(r);
......
......@@ -31,7 +31,8 @@ public class Db {
private Connection conn;
private Statement stat;
private final HashMap<String, PreparedStatement> prepared = new HashMap<String, PreparedStatement>();
private final HashMap<String, PreparedStatement> prepared =
new HashMap<String, PreparedStatement>();
/**
* Create a database object using the given connection.
......
......@@ -67,7 +67,9 @@ public class TaskProcess {
writer = new BufferedWriter(new OutputStreamWriter(process.getOutputStream()));
String line = reader.readLine();
if (line == null) {
throw new RuntimeException("No reply from process, command: " + StringUtils.arrayCombine(procDef, ' '));
throw new RuntimeException(
"No reply from process, command: " +
StringUtils.arrayCombine(procDef, ' '));
} else if (line.startsWith("running")) {
traceOperation("got reply: " + line);
} else if (line.startsWith("init error")) {
......
......@@ -78,7 +78,8 @@ public class TestBackup extends TestBase {
}
};
Connection conn2;
conn2 = getConnection(url + ";database_event_listener='" + BackupListener.class.getName() + "'");
conn2 = getConnection(url + ";database_event_listener='" +
BackupListener.class.getName() + "'");
Statement stat2 = conn2.createStatement();
task.execute();
for (int i = 0; i < 10; i++) {
......@@ -90,7 +91,8 @@ public class TestBackup extends TestBase {
conn3 = getConnection("t2/backup");
Statement stat3 = conn3.createStatement();
stat3.execute("script");
ResultSet rs = stat3.executeQuery("select * from test where name='Hallo'");
ResultSet rs = stat3.executeQuery(
"select * from test where name='Hallo'");
while (rs.next()) {
fail();
}
......@@ -145,21 +147,27 @@ public class TestBackup extends TestBase {
private void testBackupRestoreLob() throws SQLException {
deleteDb("backup");
Connection conn = getConnection("backup");
conn.createStatement().execute("create table test(x clob) as select space(10000)");
conn.createStatement().execute(
"create table test(x clob) as select space(10000)");
conn.close();
Backup.execute(getBaseDir() + "/backup.zip", getBaseDir(), "backup", true);
Backup.execute(getBaseDir() + "/backup.zip",
getBaseDir(), "backup", true);
deleteDb("backup");
Restore.execute(getBaseDir() + "/backup.zip", getBaseDir(), "backup");
Restore.execute(getBaseDir() + "/backup.zip",
getBaseDir(), "backup");
}
private void testBackupRestoreLobStatement() throws SQLException {
deleteDb("backup");
Connection conn = getConnection("backup");
conn.createStatement().execute("create table test(x clob) as select space(10000)");
conn.createStatement().execute("backup to '" +getBaseDir() + "/backup.zip"+"'");
conn.createStatement().execute(
"create table test(x clob) as select space(10000)");
conn.createStatement().execute("backup to '" +
getBaseDir() + "/backup.zip"+"'");
conn.close();
deleteDb("backup");
Restore.execute(getBaseDir() + "/backup.zip", getBaseDir(), "backup");
Restore.execute(getBaseDir() + "/backup.zip",
getBaseDir(), "backup");
}
private void testBackup() throws SQLException {
......@@ -169,10 +177,14 @@ public class TestBackup extends TestBase {
Statement stat1, stat2, stat3;
conn1 = getConnection("backup");
stat1 = conn1.createStatement();
stat1.execute("create table test(id int primary key, name varchar(255))");
stat1.execute("insert into test values(1, 'first'), (2, 'second')");
stat1.execute("create table testlob(id int primary key, b blob, c clob)");
stat1.execute("insert into testlob values(1, space(10000), repeat('00', 10000))");
stat1.execute("create table test" +
"(id int primary key, name varchar(255))");
stat1.execute("insert into test values" +
"(1, 'first'), (2, 'second')");
stat1.execute("create table testlob" +
"(id int primary key, b blob, c clob)");
stat1.execute("insert into testlob values" +
"(1, space(10000), repeat('00', 10000))");
conn2 = getConnection("backup");
stat2 = conn2.createStatement();
stat2.execute("insert into test values(3, 'third')");
......
......@@ -47,30 +47,46 @@ public class TestBigDb extends TestBase {
deleteDb("bigDb");
Connection conn = getConnection("bigDb");
Statement stat = conn.createStatement();
stat.execute("CREATE CACHED TABLE TEST(" + "M_CODE CHAR(1) DEFAULT CAST(RAND()*9 AS INT),"
+ "PRD_CODE CHAR(20) DEFAULT SECURE_RAND(10)," + "ORG_CODE_SUPPLIER CHAR(13) DEFAULT SECURE_RAND(6),"
+ "PRD_CODE_1 CHAR(14) DEFAULT SECURE_RAND(7)," + "PRD_CODE_2 CHAR(20) DEFAULT SECURE_RAND(10),"
+ "ORG_CODE CHAR(13) DEFAULT SECURE_RAND(6)," + "SUBSTITUTED_BY CHAR(20) DEFAULT SECURE_RAND(10),"
stat.execute("CREATE CACHED TABLE TEST("
+ "M_CODE CHAR(1) DEFAULT CAST(RAND()*9 AS INT),"
+ "PRD_CODE CHAR(20) DEFAULT SECURE_RAND(10),"
+ "ORG_CODE_SUPPLIER CHAR(13) DEFAULT SECURE_RAND(6),"
+ "PRD_CODE_1 CHAR(14) DEFAULT SECURE_RAND(7),"
+ "PRD_CODE_2 CHAR(20) DEFAULT SECURE_RAND(10),"
+ "ORG_CODE CHAR(13) DEFAULT SECURE_RAND(6),"
+ "SUBSTITUTED_BY CHAR(20) DEFAULT SECURE_RAND(10),"
+ "SUBSTITUTED_BY_2 CHAR(14) DEFAULT SECURE_RAND(7),"
+ "SUBSTITUTION_FOR CHAR(20) DEFAULT SECURE_RAND(10),"
+ "SUBSTITUTION_FOR_2 CHAR(14) DEFAULT SECURE_RAND(7)," + "TEST CHAR(2) DEFAULT SECURE_RAND(1),"
+ "TEST_2 CHAR(2) DEFAULT SECURE_RAND(1)," + "TEST_3 DECIMAL(7,2) DEFAULT RAND(),"
+ "SUBSTITUTION_FOR_2 CHAR(14) DEFAULT SECURE_RAND(7),"
+ "TEST CHAR(2) DEFAULT SECURE_RAND(1),"
+ "TEST_2 CHAR(2) DEFAULT SECURE_RAND(1),"
+ "TEST_3 DECIMAL(7,2) DEFAULT RAND(),"
+ "PRIMARY_UNIT_CODE CHAR(3) DEFAULT SECURE_RAND(1),"
+ "RATE_PRICE_ORDER_UNIT DECIMAL(9,3) DEFAULT RAND(),"
+ "ORDER_UNIT_CODE CHAR(3) DEFAULT SECURE_RAND(1)," + "ORDER_QTY_MIN DECIMAL(6,1) DEFAULT RAND(),"
+ "ORDER_UNIT_CODE CHAR(3) DEFAULT SECURE_RAND(1),"
+ "ORDER_QTY_MIN DECIMAL(6,1) DEFAULT RAND(),"
+ "ORDER_QTY_LOT_SIZE DECIMAL(6,1) DEFAULT RAND(),"
+ "ORDER_UNIT_CODE_2 CHAR(3) DEFAULT SECURE_RAND(1)," + "PRICE_GROUP CHAR(20) DEFAULT SECURE_RAND(10),"
+ "LEAD_TIME INTEGER DEFAULT RAND()," + "LEAD_TIME_UNIT_CODE CHAR(3) DEFAULT SECURE_RAND(1),"
+ "PRD_GROUP CHAR(10) DEFAULT SECURE_RAND(5)," + "WEIGHT_GROSS DECIMAL(7,3) DEFAULT RAND(),"
+ "WEIGHT_UNIT_CODE CHAR(3) DEFAULT SECURE_RAND(1)," + "PACK_UNIT_CODE CHAR(3) DEFAULT SECURE_RAND(1),"
+ "PACK_LENGTH DECIMAL(7,3) DEFAULT RAND()," + "PACK_WIDTH DECIMAL(7,3) DEFAULT RAND(),"
+ "PACK_HEIGHT DECIMAL(7,3) DEFAULT RAND()," + "SIZE_UNIT_CODE CHAR(3) DEFAULT SECURE_RAND(1),"
+ "STATUS_CODE CHAR(3) DEFAULT SECURE_RAND(1)," + "INTRA_STAT_CODE CHAR(12) DEFAULT SECURE_RAND(6),"
+ "PRD_TITLE CHAR(50) DEFAULT SECURE_RAND(25)," + "VALID_FROM DATE DEFAULT NOW(),"
+ "ORDER_UNIT_CODE_2 CHAR(3) DEFAULT SECURE_RAND(1),"
+ "PRICE_GROUP CHAR(20) DEFAULT SECURE_RAND(10),"
+ "LEAD_TIME INTEGER DEFAULT RAND(),"
+ "LEAD_TIME_UNIT_CODE CHAR(3) DEFAULT SECURE_RAND(1),"
+ "PRD_GROUP CHAR(10) DEFAULT SECURE_RAND(5),"
+ "WEIGHT_GROSS DECIMAL(7,3) DEFAULT RAND(),"
+ "WEIGHT_UNIT_CODE CHAR(3) DEFAULT SECURE_RAND(1),"
+ "PACK_UNIT_CODE CHAR(3) DEFAULT SECURE_RAND(1),"
+ "PACK_LENGTH DECIMAL(7,3) DEFAULT RAND(),"
+ "PACK_WIDTH DECIMAL(7,3) DEFAULT RAND(),"
+ "PACK_HEIGHT DECIMAL(7,3) DEFAULT RAND(),"
+ "SIZE_UNIT_CODE CHAR(3) DEFAULT SECURE_RAND(1),"
+ "STATUS_CODE CHAR(3) DEFAULT SECURE_RAND(1),"
+ "INTRA_STAT_CODE CHAR(12) DEFAULT SECURE_RAND(6),"
+ "PRD_TITLE CHAR(50) DEFAULT SECURE_RAND(25),"
+ "VALID_FROM DATE DEFAULT NOW(),"
+ "MOD_DATUM DATE DEFAULT NOW())");
int len = getSize(10, 50000);
try {
PreparedStatement prep = conn.prepareStatement("INSERT INTO TEST(PRD_CODE) VALUES('abc' || ?)");
PreparedStatement prep = conn.prepareStatement(
"INSERT INTO TEST(PRD_CODE) VALUES('abc' || ?)");
long time = System.currentTimeMillis();
for (int i = 0; i < len; i++) {
if ((i % 1000) == 0) {
......@@ -104,9 +120,11 @@ public class TestBigDb extends TestBase {
deleteDb("bigDb");
Connection conn = getConnection("bigDb");
Statement stat = conn.createStatement();
stat.execute("CREATE TABLE TEST(ID INT, NEG INT AS -ID, NAME VARCHAR, PRIMARY KEY(ID, NAME))");
stat.execute("CREATE TABLE TEST(ID INT, NEG INT AS -ID, " +
"NAME VARCHAR, PRIMARY KEY(ID, NAME))");
stat.execute("CREATE INDEX IDX_NEG ON TEST(NEG, NAME)");
PreparedStatement prep = conn.prepareStatement("INSERT INTO TEST(ID, NAME) VALUES(?, '1234567890')");
PreparedStatement prep = conn.prepareStatement(
"INSERT INTO TEST(ID, NAME) VALUES(?, '1234567890')");
int len = getSize(10, 1000);
int block = getSize(3, 10);
int left, x = 0;
......@@ -130,7 +148,8 @@ public class TestBigDb extends TestBase {
Connection conn = getConnection("bigDb");
Statement stat = conn.createStatement();
stat.execute("CREATE TABLE TEST(ID IDENTITY, NAME VARCHAR)");
PreparedStatement prep = conn.prepareStatement("INSERT INTO TEST(NAME) VALUES('Hello World')");
PreparedStatement prep = conn.prepareStatement(
"INSERT INTO TEST(NAME) VALUES('Hello World')");
int len = getSize(1000, 10000);
for (int i = 0; i < len; i++) {
if (i % 1000 == 0) {
......
......@@ -53,7 +53,8 @@ public class TestBigResult extends TestBase {
stat.execute("INSERT INTO RECOVERY " +
"SELECT X, CASE MOD(X, 2) WHEN 0 THEN 'commit' ELSE 'begin' END " +
"FROM SYSTEM_RANGE(1, "+len+")");
ResultSet rs = stat.executeQuery("SELECT * FROM RECOVERY WHERE SQL_STMT LIKE 'begin%' AND " +
ResultSet rs = stat.executeQuery("SELECT * FROM RECOVERY " +
"WHERE SQL_STMT LIKE 'begin%' AND " +
"TRANSACTION_ID NOT IN(SELECT TRANSACTION_ID FROM RECOVERY " +
"WHERE SQL_STMT='commit' OR SQL_STMT='rollback')");
int count = 0, last = 1;
......@@ -90,7 +91,8 @@ public class TestBigResult extends TestBase {
// rs.close();
conn.close();
deleteDb("bigResult");
ArrayList<String> files = FileLister.getDatabaseFiles(getBaseDir(), "bigResult", true);
ArrayList<String> files = FileLister.getDatabaseFiles(getBaseDir(),
"bigResult", true);
if (files.size() > 0) {
fail("file not deleted: " + files.get(0));
}
......@@ -134,7 +136,8 @@ public class TestBigResult extends TestBase {
"Points INT," +
"LicenseID INT)");
int len = getSize(10, 5000);
PreparedStatement prep = conn.prepareStatement("INSERT INTO TEST VALUES(?, ?, ?, ?, ?)");
PreparedStatement prep = conn.prepareStatement(
"INSERT INTO TEST VALUES(?, ?, ?, ?, ?)");
for (int i = 0; i < len; i++) {
prep.setInt(1, i);
prep.setString(2, "Name " + i);
......@@ -185,7 +188,8 @@ public class TestBigResult extends TestBase {
prep.setString(2, "" + i / 200);
prep.execute();
}
Statement s2 = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
Statement s2 = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
rs = s2.executeQuery("SELECT NAME FROM DATA");
rs.last();
conn.setAutoCommit(true);
......
......@@ -49,8 +49,10 @@ public class TestCompatibilityOracle extends TestBase {
assertResult("1", stat, "SELECT COUNT(*) FROM A WHERE X IS NULL");
assertResult("2", stat, "SELECT COUNT(*) FROM A WHERE TRIM(X) IS NULL");
assertResult("0", stat, "SELECT COUNT(*) FROM A WHERE X = ''");
assertResult(new Object[][] { { 1, "a" }, { 2, null }, { 3, " " } }, stat, "SELECT * FROM A");
assertResult(new Object[][] { { 1, "a" }, { 2, null }, { 3, null } }, stat, "SELECT ID, TRIM(X) FROM A");
assertResult(new Object[][] { { 1, "a" }, { 2, null }, { 3, " " } },
stat, "SELECT * FROM A");
assertResult(new Object[][] { { 1, "a" }, { 2, null }, { 3, null } },
stat, "SELECT ID, TRIM(X) FROM A");
stat.execute("CREATE TABLE B (ID NUMBER, X NUMBER)");
stat.execute("INSERT INTO B VALUES (1, '5')");
......@@ -58,7 +60,8 @@ public class TestCompatibilityOracle extends TestBase {
assertResult("2", stat, "SELECT COUNT(*) FROM B");
assertResult("1", stat, "SELECT COUNT(*) FROM B WHERE X IS NULL");
assertResult("0", stat, "SELECT COUNT(*) FROM B WHERE X = ''");
assertResult(new Object[][] { { 1, 5 }, { 2, null } }, stat, "SELECT * FROM B");
assertResult(new Object[][] { { 1, 5 }, { 2, null } },
stat, "SELECT * FROM B");
stat.execute("CREATE TABLE C (ID NUMBER, X TIMESTAMP)");
stat.execute("INSERT INTO C VALUES (1, '1979-11-12')");
......@@ -66,7 +69,8 @@ public class TestCompatibilityOracle extends TestBase {
assertResult("2", stat, "SELECT COUNT(*) FROM C");
assertResult("1", stat, "SELECT COUNT(*) FROM C WHERE X IS NULL");
assertResult("0", stat, "SELECT COUNT(*) FROM C WHERE X = ''");
assertResult(new Object[][] { { 1, "1979-11-12 00:00:00.0" }, { 2, null } }, stat, "SELECT * FROM C");
assertResult(new Object[][] { { 1, "1979-11-12 00:00:00.0" }, { 2, null } },
stat, "SELECT * FROM C");
stat.execute("CREATE TABLE D (ID NUMBER, X VARCHAR2(1))");
stat.execute("INSERT INTO D VALUES (1, 'a')");
......@@ -75,7 +79,8 @@ public class TestCompatibilityOracle extends TestBase {
assertResult("2", stat, "SELECT COUNT(*) FROM D");
assertResult("1", stat, "SELECT COUNT(*) FROM D WHERE X IS NULL");
assertResult("0", stat, "SELECT COUNT(*) FROM D WHERE X = ''");
assertResult(new Object[][] { { 1, "a" }, { 2, null } }, stat, "SELECT * FROM D");
assertResult(new Object[][] { { 1, "a" }, { 2, null } },
stat, "SELECT * FROM D");
stat.execute("CREATE TABLE E (ID NUMBER, X RAW(1))");
stat.execute("INSERT INTO E VALUES (1, '0A')");
......@@ -83,7 +88,8 @@ public class TestCompatibilityOracle extends TestBase {
assertResult("2", stat, "SELECT COUNT(*) FROM E");
assertResult("1", stat, "SELECT COUNT(*) FROM E WHERE X IS NULL");
assertResult("0", stat, "SELECT COUNT(*) FROM E WHERE X = ''");
assertResult(new Object[][] { { 1, new byte[] { 10 } }, { 2, null } }, stat, "SELECT * FROM E");
assertResult(new Object[][] { { 1, new byte[] { 10 } }, { 2, null } },
stat, "SELECT * FROM E");
conn.close();
}
......@@ -98,16 +104,19 @@ public class TestCompatibilityOracle extends TestBase {
stat.execute("INSERT INTO A VALUES (2, 4.3)");
stat.execute("INSERT INTO A VALUES (3, '6.78')");
assertResult("3", stat, "SELECT COUNT(*) FROM A");
assertResult(new Object[][] { { 1, 2 }, { 2, 4.3 }, { 3, 6.78 } }, stat, "SELECT * FROM A");
assertResult(new Object[][] { { 1, 2 }, { 2, 4.3 }, { 3, 6.78 } },
stat, "SELECT * FROM A");
conn.close();
}
private void assertResult(Object[][] expectedRowsOfValues, Statement stat, String sql) throws SQLException {
private void assertResult(Object[][] expectedRowsOfValues, Statement stat,
String sql) throws SQLException {
assertResult(newSimpleResultSet(expectedRowsOfValues), stat, sql);
}
private void assertResult(ResultSet expected, Statement stat, String sql) throws SQLException {
private void assertResult(ResultSet expected, Statement stat, String sql)
throws SQLException {
ResultSet actual = stat.executeQuery(sql);
int expectedColumnCount = expected.getMetaData().getColumnCount();
assertEquals(expectedColumnCount, actual.getMetaData().getColumnCount());
......
......@@ -64,7 +64,8 @@ public class TestDateStorage extends TestBase {
TimeZone.setDefault(tz);
DateTimeUtils.resetCalendar();
conn = getConnection(db);
PreparedStatement prep = conn.prepareStatement("insert into date_list values(?, ?, ?)");
PreparedStatement prep = conn.prepareStatement(
"insert into date_list values(?, ?, ?)");
prep.setString(1, tz.getID());
for (int m = 1; m < 10; m++) {
String s = "2000-0" + m + "-01 15:00:00";
......
......@@ -66,7 +66,8 @@ public class TestDeadlock extends TestBase {
conn2 = getConnection(url);
final Statement stat = conn.createStatement();
Statement stat2 = conn2.createStatement();
stat.execute("create alias if not exists ft_init for \"org.h2.fulltext.FullText.init\"");
stat.execute("create alias if not exists ft_init for " +
"\"org.h2.fulltext.FullText.init\"");
stat.execute("call ft_init()");
stat.execute("create table test(id int primary key, name varchar)");
stat.execute("call ft_create_index('PUBLIC', 'TEST', null)");
......
......@@ -57,7 +57,8 @@ public class TestDrop extends TestBase {
stat.execute("DROP ALL OBJECTS");
stat.execute("CREATE SCHEMA TEST_SCHEMA");
stat.execute("CREATE TABLE TEST_SCHEMA.A (A INT);");
stat.execute("CREATE TABLE TEST_SCHEMA.B (B INT AS SELECT A FROM TEST_SCHEMA.A);");
stat.execute("CREATE TABLE TEST_SCHEMA.B " +
"(B INT AS SELECT A FROM TEST_SCHEMA.A);");
stat.execute("DROP SCHEMA TEST_SCHEMA");
}
......
......@@ -80,29 +80,40 @@ public class TestDuplicateKeyUpdate extends TestBase {
Statement stat = conn.createStatement();
ResultSet rs;
stat.execute("CREATE TABLE table_test2 (\n" + " id bigint(20) NOT NULL AUTO_INCREMENT,\n"
+ " a_text varchar(254) NOT NULL,\n" + " some_text varchar(254) NOT NULL,\n"
+ " updatable_text varchar(254) NULL,\n" + " PRIMARY KEY (id)\n" + ") ;");
stat.execute("CREATE UNIQUE INDEX index_name \n" + "ON table_test2 (a_text, some_text);");
stat.execute("INSERT INTO table_test2 ( a_text, some_text, updatable_text ) VALUES ('a', 'a', '1')");
stat.execute("INSERT INTO table_test2 ( a_text, some_text, updatable_text ) VALUES ('b', 'b', '2')");
stat.execute("INSERT INTO table_test2 ( a_text, some_text, updatable_text ) VALUES ('c', 'c', '3')");
stat.execute("INSERT INTO table_test2 ( a_text, some_text, updatable_text ) VALUES ('d', 'd', '4')");
stat.execute("INSERT INTO table_test2 ( a_text, some_text, updatable_text ) VALUES ('e', 'e', '5')");
stat.execute("CREATE TABLE table_test2 (\n"
+ " id bigint(20) NOT NULL AUTO_INCREMENT,\n"
+ " a_text varchar(254) NOT NULL,\n"
+ " some_text varchar(254) NOT NULL,\n"
+ " updatable_text varchar(254) NULL,\n"
+ " PRIMARY KEY (id)\n" + ") ;");
stat.execute("CREATE UNIQUE INDEX index_name \n"
+ "ON table_test2 (a_text, some_text);");
stat.execute("INSERT INTO table_test2 " +
"( a_text, some_text, updatable_text ) VALUES ('a', 'a', '1')");
stat.execute("INSERT INTO table_test2 " +
"( a_text, some_text, updatable_text ) VALUES ('b', 'b', '2')");
stat.execute("INSERT INTO table_test2 " +
"( a_text, some_text, updatable_text ) VALUES ('c', 'c', '3')");
stat.execute("INSERT INTO table_test2 " +
"( a_text, some_text, updatable_text ) VALUES ('d', 'd', '4')");
stat.execute("INSERT INTO table_test2 " +
"( a_text, some_text, updatable_text ) VALUES ('e', 'e', '5')");
stat.execute("INSERT INTO table_test2 ( a_text, some_text ) " +
"VALUES ('e', 'e') ON DUPLICATE KEY UPDATE updatable_text='UPDATE'");
rs = stat.executeQuery("SELECT updatable_text FROM table_test2 where a_text = 'e'");
rs = stat.executeQuery("SELECT updatable_text " +
"FROM table_test2 where a_text = 'e'");
rs.next();
assertEquals("UPDATE", rs.getNString(1));
stat.execute("INSERT INTO table_test2 (a_text, some_text, updatable_text ) " +
"VALUES ('b', 'b', 'test') " +
"ON DUPLICATE KEY UPDATE updatable_text=values(updatable_text)");
rs = stat.executeQuery("SELECT updatable_text FROM table_test2 where a_text = 'b'");
rs = stat.executeQuery("SELECT updatable_text " +
"FROM table_test2 where a_text = 'b'");
rs.next();
assertEquals("test", rs.getNString(1));
}
......@@ -154,16 +165,20 @@ public class TestDuplicateKeyUpdate extends TestBase {
stat.execute("INSERT INTO table_test4 ( id, a_text, some_value ) " +
"VALUES (2, 'aaaaaaaaaa', 5)");
stat.execute("INSERT INTO table_test4 ( id , a_text, some_value ) VALUES (1, 'b', 1) " +
stat.execute("INSERT INTO table_test4 ( id , a_text, some_value ) " +
"VALUES (1, 'b', 1) " +
"ON DUPLICATE KEY UPDATE some_value=some_value + values(some_value)");
stat.execute("INSERT INTO table_test4 ( id , a_text, some_value ) VALUES (1, 'b', 1) " +
stat.execute("INSERT INTO table_test4 ( id , a_text, some_value ) " +
"VALUES (1, 'b', 1) " +
"ON DUPLICATE KEY UPDATE some_value=some_value + 100");
stat.execute("INSERT INTO table_test4 ( id , a_text, some_value ) VALUES (2, 'b', 1) " +
stat.execute("INSERT INTO table_test4 ( id , a_text, some_value ) " +
"VALUES (2, 'b', 1) " +
"ON DUPLICATE KEY UPDATE some_value=values(some_value) + 1");
rs = stat.executeQuery("SELECT some_value FROM table_test4 where id = 1");
rs.next();
assertEquals(106, rs.getInt(1));
rs = stat.executeQuery("SELECT some_value FROM table_test4 where id = 2");
rs = stat.executeQuery(
"SELECT some_value FROM table_test4 where id = 2");
rs.next();
assertEquals(2, rs.getInt(1));
}
......@@ -171,7 +186,8 @@ public class TestDuplicateKeyUpdate extends TestBase {
public void testOnDuplicateKeyInsertBatch(Connection conn)
throws SQLException {
Statement stat = conn.createStatement();
stat.execute("create table test (key varchar(1) primary key, count int not null)");
stat.execute("create table test " +
"(key varchar(1) primary key, count int not null)");
// Insert multiple values as a batch
for (int i = 0; i <= 2; ++i) {
......@@ -191,7 +207,8 @@ public class TestDuplicateKeyUpdate extends TestBase {
}
// Check result
ResultSet rs = stat.executeQuery("select count from test where key = 'a'");
ResultSet rs = stat.executeQuery(
"select count from test where key = 'a'");
rs.next();
assertEquals(3, rs.getInt(1));
......@@ -201,7 +218,8 @@ public class TestDuplicateKeyUpdate extends TestBase {
public void testOnDuplicateKeyInsertMultiValue(Connection conn)
throws SQLException {
Statement stat = conn.createStatement();
stat.execute("create table test(key varchar(1) primary key, count int not null)");
stat.execute("create table test" +
"(key varchar(1) primary key, count int not null)");
// Insert multiple values in single insert operation
for (int i = 0; i <= 2; ++i) {
......
......@@ -89,7 +89,8 @@ public class TestFunctionOverload extends TestBase {
private void testOverloadNamedArgs() throws SQLException {
Statement stat = conn.createStatement();
stat.execute("create alias overload1or2Named for \"" + ME + ".overload1or2(int)\"");
stat.execute("create alias overload1or2Named for \"" + ME +
".overload1or2(int)\"");
ResultSet rs = stat.executeQuery("select overload1or2Named(1) from dual");
assertTrue("First Row", rs.next());
......@@ -104,7 +105,8 @@ public class TestFunctionOverload extends TestBase {
private void testOverloadWithConnection() throws SQLException {
Statement stat = conn.createStatement();
stat.execute("create alias overload1or2WithConn for \"" + ME + ".overload1or2WithConn\"");
stat.execute("create alias overload1or2WithConn for \"" + ME +
".overload1or2WithConn\"");
ResultSet rs = stat.executeQuery("select overload1or2WithConn(1) from dual");
rs.next();
......@@ -158,7 +160,8 @@ public class TestFunctionOverload extends TestBase {
* @param one the value
* @return the value
*/
public static int overload1or2WithConn(Connection conn, int one) throws SQLException {
public static int overload1or2WithConn(Connection conn, int one)
throws SQLException {
conn.createStatement().executeQuery("select 1 from dual");
return one;
}
......
......@@ -188,7 +188,8 @@ public class TestView extends TestBase {
for (int i = 0; i < 30; i++) {
s.execute("create view t" + (i + 1) + " as select * from t" + i);
s.execute("select * from t" + (i + 1));
ResultSet rs = s.executeQuery("select count(*) from t" + (i + 1) + " where id=2");
ResultSet rs = s.executeQuery(
"select count(*) from t" + (i + 1) + " where id=2");
assertTrue(rs.next());
assertEquals(1, rs.getInt(1));
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论