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

throw the most specific exception

上级 8e8786dc
......@@ -348,7 +348,7 @@ http://www.w3schools.com/sql/
/**
* Run all tests in all possible combinations.
*/
private void testEverything() throws Exception {
private void testEverything() throws SQLException {
for (int c = 0; c < 3; c++) {
if (c == 0) {
cipher = null;
......@@ -377,7 +377,7 @@ http://www.w3schools.com/sql/
/**
* Run the tests with a number of different settings.
*/
private void runTests() throws Exception {
private void runTests() throws SQLException {
jdk14 = true;
smallLog = big = networked = memory = ssl = textStorage = false;
diskResult = deleteIndex = traceSystemOut = diskUndo = false;
......@@ -446,7 +446,7 @@ http://www.w3schools.com/sql/
/**
* Run all tests with the current settings.
*/
private void test() throws Exception {
private void test() throws SQLException {
System.out.println();
System.out.println("Test " + toString());
beforeTest();
......
......@@ -424,7 +424,7 @@ public abstract class TestBase {
/**
* This method will be called by the test framework.
*
* @throws AssertionError if an exception in the test occurs
* @throws Exception if an exception in the test occurs
*/
public abstract void test() throws Exception;
......
......@@ -6,6 +6,8 @@
*/
package org.h2.test.bench;
import java.sql.SQLException;
/**
* The interface for benchmark tests.
*/
......@@ -17,7 +19,7 @@ public interface Bench {
* @param db the database object
* @param size the amount of data
*/
void init(Database db, int size) throws Exception;
void init(Database db, int size) throws SQLException;
/**
* Run the test.
......
......@@ -8,6 +8,7 @@ package org.h2.test.bench;
import java.math.BigDecimal;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Random;
/**
......@@ -28,7 +29,7 @@ public class BenchA implements Bench {
private int accounts;
private int size;
public void init(Database db, int size) throws Exception {
public void init(Database db, int size) throws SQLException {
this.db = db;
this.size = size;
......@@ -97,7 +98,7 @@ public class BenchA implements Bench {
// db.end();
}
public void runTest() throws Exception {
public void runTest() throws SQLException {
db.start(this, "Transactions");
db.openConnection();
......@@ -112,7 +113,7 @@ public class BenchA implements Bench {
}
private void processTransactions() throws Exception {
private void processTransactions() throws SQLException {
Random random = db.getRandom();
int branch = random.nextInt(branches);
int teller = random.nextInt(tellers);
......
......@@ -44,7 +44,7 @@ public class BenchB implements Bench, Runnable {
// nothing to do
}
private BenchB(BenchB master, int seed) throws Exception {
private BenchB(BenchB master, int seed) throws SQLException {
this.master = master;
random = new Random(seed);
conn = master.db.openNewConnection();
......@@ -61,7 +61,7 @@ public class BenchB implements Bench, Runnable {
"INSERT INTO HISTORY(TID, BID, AID, DELTA) VALUES(?, ?, ?, ?)");
}
public void init(Database db, int size) throws Exception {
public void init(Database db, int size) throws SQLException {
this.db = db;
this.transactionPerClient = size;
......
......@@ -8,6 +8,7 @@ package org.h2.test.bench;
import java.math.BigDecimal;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.sql.Types;
......@@ -102,7 +103,7 @@ public class BenchC implements Bench {
private int commitEvery = 1000;
public void init(Database db, int size) throws Exception {
public void init(Database db, int size) throws SQLException {
this.db = db;
random = new BenchCRandom();
......@@ -127,7 +128,7 @@ public class BenchC implements Bench {
}
private void load() throws Exception {
private void load() throws SQLException {
for (int i = 0; i < TABLES.length; i++) {
db.dropTable(TABLES[i]);
}
......@@ -151,7 +152,7 @@ public class BenchC implements Bench {
db.trace(action, i, max);
}
private void loadItem() throws Exception {
private void loadItem() throws SQLException {
trace("Loading item table");
boolean[] original = random.getBoolean(items, items / 10);
PreparedStatement prep = db.prepare("INSERT INTO ITEM(I_ID, I_IM_ID, I_NAME, I_PRICE, I_DATA) "
......@@ -176,7 +177,7 @@ public class BenchC implements Bench {
}
}
private void loadWarehouse() throws Exception {
private void loadWarehouse() throws SQLException {
trace("Loading warehouse table");
PreparedStatement prep = db.prepare("INSERT INTO WAREHOUSE(W_ID, W_NAME, W_STREET_1, "
+ "W_STREET_2, W_CITY, W_STATE, W_ZIP, W_TAX, W_YTD) " + "VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)");
......@@ -208,7 +209,7 @@ public class BenchC implements Bench {
}
}
private void loadCustomer() throws Exception {
private void loadCustomer() throws SQLException {
trace("Load customer table");
int max = warehouses * districtsPerWarehouse;
int i = 0;
......@@ -223,7 +224,7 @@ public class BenchC implements Bench {
}
}
private void loadCustomerSub(int dId, int wId) throws Exception {
private void loadCustomerSub(int dId, int wId) throws SQLException {
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
PreparedStatement prepCustomer = db.prepare("INSERT INTO CUSTOMER(C_ID, C_D_ID, C_W_ID, "
+ "C_FIRST, C_MIDDLE, C_LAST, " + "C_STREET_1, C_STREET_2, C_CITY, C_STATE, C_ZIP, "
......@@ -297,7 +298,7 @@ public class BenchC implements Bench {
}
}
private void loadOrder() throws Exception {
private void loadOrder() throws SQLException {
trace("Loading order table");
int max = warehouses * districtsPerWarehouse;
int i = 0;
......@@ -309,7 +310,7 @@ public class BenchC implements Bench {
}
}
private void loadOrderSub(int dId, int wId) throws Exception {
private void loadOrderSub(int dId, int wId) throws SQLException {
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
int[] orderid = random.getPermutation(ordersPerDistrict);
PreparedStatement prepOrder = db.prepare("INSERT INTO ORDERS(O_ID, O_C_ID, O_D_ID, O_W_ID, "
......@@ -368,7 +369,7 @@ public class BenchC implements Bench {
}
}
private void loadStock(int wId) throws Exception {
private void loadStock(int wId) throws SQLException {
trace("Loading stock table (warehouse " + wId + ")");
boolean[] original = random.getBoolean(items, items / 10);
PreparedStatement prep = db.prepare("INSERT INTO STOCK(S_I_ID, S_W_ID, S_QUANTITY, "
......@@ -417,7 +418,7 @@ public class BenchC implements Bench {
}
}
private void loadDistrict(int wId) throws Exception {
private void loadDistrict(int wId) throws SQLException {
BigDecimal ytd = new BigDecimal("300000.00");
int nextId = 3001;
PreparedStatement prep = db.prepare("INSERT INTO DISTRICT(D_ID, D_W_ID, D_NAME, "
......@@ -448,7 +449,7 @@ public class BenchC implements Bench {
}
}
public void runTest() throws Exception {
public void runTest() throws SQLException {
db.start(this, "Transactions");
db.openConnection();
for (int i = 0; i < 70; i++) {
......
......@@ -9,6 +9,7 @@ package org.h2.test.bench;
import java.math.BigDecimal;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.HashMap;
......@@ -30,7 +31,7 @@ public class BenchCThread {
private BenchC bench;
BenchCThread(Database db, BenchC bench, BenchCRandom random, int terminal)
throws Exception {
throws SQLException {
this.db = db;
this.bench = bench;
this.terminalId = terminal;
......@@ -42,7 +43,7 @@ public class BenchCThread {
/**
* Process the list of operations (a 'deck') in random order.
*/
void process() throws Exception {
void process() throws SQLException {
int[] deck = new int[] { OP_NEW_ORDER, OP_NEW_ORDER, OP_NEW_ORDER,
OP_NEW_ORDER, OP_NEW_ORDER, OP_NEW_ORDER, OP_NEW_ORDER,
OP_NEW_ORDER, OP_NEW_ORDER, OP_NEW_ORDER, OP_PAYMENT,
......@@ -80,7 +81,7 @@ public class BenchCThread {
}
}
private void processNewOrder() throws Exception {
private void processNewOrder() throws SQLException {
int dId = random.getInt(1, bench.districtsPerWarehouse);
int cId = random.getNonUniform(1023, 1, bench.customersPerDistrict);
int olCnt = random.getInt(5, 15);
......@@ -166,7 +167,7 @@ public class BenchCThread {
db.rollback();
return;
}
throw new Exception("item not found: " + olId + " "
throw new SQLException("item not found: " + olId + " "
+ olSupplyId);
}
BigDecimal price = rs.getBigDecimal(1);
......@@ -187,7 +188,7 @@ public class BenchCThread {
db.rollback();
return;
}
throw new Exception("item not found: " + olId + " "
throw new SQLException("item not found: " + olId + " "
+ olSupplyId);
}
int sQuantity = rs.getInt(1);
......@@ -257,7 +258,7 @@ public class BenchCThread {
db.commit();
}
private void processPayment() throws Exception {
private void processPayment() throws SQLException {
int dId = random.getInt(1, bench.districtsPerWarehouse);
int wId, cdId;
if (bench.warehouses > 1 && random.getInt(1, 100) <= 15) {
......@@ -482,7 +483,7 @@ public class BenchCThread {
db.commit();
}
private void processOrderStatus() throws Exception {
private void processOrderStatus() throws SQLException {
int dId = random.getInt(1, bench.districtsPerWarehouse);
boolean byName;
String last = null;
......@@ -604,7 +605,7 @@ public class BenchCThread {
db.commit();
}
private void processDelivery() throws Exception {
private void processDelivery() throws SQLException {
int carrierId = random.getInt(1, 10);
Timestamp datetime = new Timestamp(System.currentTimeMillis());
PreparedStatement prep;
......@@ -678,7 +679,7 @@ public class BenchCThread {
db.commit();
}
private void processStockLevel() throws Exception {
private void processStockLevel() throws SQLException {
int dId = (terminalId % bench.districtsPerWarehouse) + 1;
int threshold = random.getInt(10, 20);
PreparedStatement prep;
......@@ -724,7 +725,7 @@ public class BenchCThread {
db.commit();
}
private PreparedStatement prepare(String sql) throws Exception {
private PreparedStatement prepare(String sql) throws SQLException {
PreparedStatement prep = (PreparedStatement) prepared.get(sql);
if (prep == null) {
prep = db.prepare(sql);
......
......@@ -7,6 +7,7 @@
package org.h2.test.bench;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Random;
/**
......@@ -19,7 +20,7 @@ public class BenchSimple implements Bench {
Database db;
int records;
public void init(Database db, int size) throws Exception {
public void init(Database db, int size) throws SQLException {
this.db = db;
this.records = size * 60;
......@@ -50,7 +51,7 @@ public class BenchSimple implements Bench {
}
public void runTest() throws Exception {
public void runTest() throws SQLException {
PreparedStatement prep;
Random random = db.getRandom();
......
......@@ -13,6 +13,7 @@ import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Properties;
......@@ -46,12 +47,12 @@ public class TestPerformance {
new TestPerformance().test(args);
}
private Connection getResultConnection() throws Exception {
Class.forName("org.h2.Driver");
private Connection getResultConnection() throws SQLException {
org.h2.Driver.load();
return DriverManager.getConnection("jdbc:h2:data/results");
}
private void openResults(boolean init) throws Exception {
private void openResults(boolean init) throws SQLException {
Connection conn = null;
Statement stat = null;
try {
......
......@@ -11,6 +11,7 @@ import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
import java.util.ArrayList;
......@@ -183,7 +184,7 @@ public class Coverage {
}
}
private void read() throws Exception {
private void read() throws IOException {
last = token;
String write = token;
token = null;
......@@ -225,14 +226,14 @@ public class Coverage {
}
}
private void readThis(String s) throws Exception {
private void readThis(String s) throws IOException {
if (!token.equals(s)) {
throw new Exception("Expected: " + s + " got:" + token);
throw new IOException("Expected: " + s + " got:" + token);
}
read();
}
private void process() throws Exception {
private void process() throws IOException {
boolean imp = false;
read();
do {
......@@ -251,7 +252,7 @@ public class Coverage {
} while (token != null);
}
private void processInit() throws Exception {
private void processInit() throws IOException {
do {
if (token.equals("{")) {
read();
......@@ -265,7 +266,7 @@ public class Coverage {
} while (true);
}
private void processClass() throws Exception {
private void processClass() throws IOException {
int type = 0;
while (true) {
if (token == null) {
......@@ -317,7 +318,7 @@ public class Coverage {
}
}
private void processBracket() throws Exception {
private void processBracket() throws IOException {
do {
if (token.equals("(")) {
read();
......@@ -331,7 +332,7 @@ public class Coverage {
} while (true);
}
private void processFunction() throws Exception {
private void processFunction() throws IOException {
function = word;
writeLine();
do {
......@@ -341,7 +342,7 @@ public class Coverage {
writeLine();
}
private void processBlockOrStatement() throws Exception {
private void processBlockOrStatement() throws IOException {
if (!token.equals("{")) {
write("{ //++");
writeLine();
......@@ -356,7 +357,7 @@ public class Coverage {
}
}
private void processStatement() throws Exception {
private void processStatement() throws IOException {
while (true) {
if (token.equals("while") || token.equals("for") || token.equals("synchronized")) {
read();
......@@ -478,12 +479,12 @@ public class Coverage {
}
}
private void setLine() throws Exception {
private void setLine() throws IOException {
add += "Profile.visit(" + index + ");";
line = tokenizer.getLine();
}
private void nextDebug() throws Exception {
private void nextDebug() throws IOException {
if (perFunction) {
int i = function.indexOf("(");
String func = i < 0 ? function : function.substring(0, i);
......@@ -498,14 +499,14 @@ public class Coverage {
index++;
}
private void writeLine() throws Exception {
private void writeLine() throws IOException {
write("\r\n");
for (int i = 0; i < indent; i++) {
writer.write(' ');
}
}
private void write(String s) throws Exception {
private void write(String s) throws IOException {
writer.write(s);
// System.out.print(s);
}
......
......@@ -148,7 +148,7 @@ public class Profile extends Thread {
lastIndex = i;
}
private void listUnvisited() throws Exception {
private void listUnvisited() throws IOException {
printLine('=');
print("NOT COVERED");
printLine('-');
......@@ -184,7 +184,7 @@ public class Profile extends Thread {
}
}
private void listTop(String title, int[] list, int max) throws Exception {
private void listTop(String title, int[] list, int max) throws IOException {
printLine('-');
int total = 0;
int totalLines = 0;
......
......@@ -18,7 +18,7 @@ import org.h2.test.TestBase;
*/
public class TestAutoRecompile extends TestBase {
public void test() throws Exception {
public void test() throws SQLException {
deleteDb("autoRecompile");
Connection conn = getConnection("autoRecompile");
Statement stat = conn.createStatement();
......
......@@ -7,6 +7,7 @@
package org.h2.test.db;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import org.h2.test.TestBase;
......@@ -17,14 +18,14 @@ import org.h2.tools.Restore;
*/
public class TestBackup extends TestBase {
public void test() throws Exception {
public void test() throws SQLException {
if (config.memory || config.logMode == 0) {
return;
}
testBackup();
}
private void testBackup() throws Exception {
private void testBackup() throws SQLException {
deleteDb("backup");
Connection conn1, conn2, conn3;
Statement stat1, stat2, stat3;
......
......@@ -9,6 +9,7 @@ package org.h2.test.db;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import org.h2.test.TestBase;
......@@ -19,7 +20,7 @@ import org.h2.util.MemoryUtils;
*/
public class TestBigDb extends TestBase {
public void test() throws Exception {
public void test() throws SQLException {
if (config.memory) {
return;
}
......@@ -31,7 +32,7 @@ public class TestBigDb extends TestBase {
testLeftSummary();
}
private void testLargeTable() throws Exception {
private void testLargeTable() throws SQLException {
deleteDb("bigDb");
Connection conn = getConnection("bigDb");
Statement stat = conn.createStatement();
......@@ -88,7 +89,7 @@ public class TestBigDb extends TestBase {
conn.close();
}
private void testLeftSummary() throws Exception {
private void testLeftSummary() throws SQLException {
deleteDb("bigDb");
Connection conn = getConnection("bigDb");
Statement stat = conn.createStatement();
......@@ -113,7 +114,7 @@ public class TestBigDb extends TestBase {
conn.close();
}
private void testInsert() throws Exception {
private void testInsert() throws SQLException {
deleteDb("bigDb");
Connection conn = getConnection("bigDb");
Statement stat = conn.createStatement();
......
......@@ -9,6 +9,7 @@ package org.h2.test.db;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
......@@ -19,7 +20,8 @@ import org.h2.test.TestBase;
* Test for big result sets.
*/
public class TestBigResult extends TestBase {
public void test() throws Exception {
public void test() throws SQLException {
if (config.memory) {
return;
}
......@@ -30,7 +32,7 @@ public class TestBigResult extends TestBase {
testLimitBufferedResult();
}
private void testLargeSubquery() throws Exception {
private void testLargeSubquery() throws SQLException {
deleteDb("bigResult");
Connection conn = getConnection("bigResult");
Statement stat = conn.createStatement();
......@@ -53,7 +55,7 @@ public class TestBigResult extends TestBase {
conn.close();
}
private void testLargeUpdateDelete() throws Exception {
private void testLargeUpdateDelete() throws SQLException {
deleteDb("bigResult");
Connection conn = getConnection("bigResult");
Statement stat = conn.createStatement();
......@@ -65,7 +67,7 @@ public class TestBigResult extends TestBase {
conn.close();
}
private void testCloseConnectionDelete() throws Exception {
private void testCloseConnectionDelete() throws SQLException {
deleteDb("bigResult");
Connection conn = getConnection("bigResult");
Statement stat = conn.createStatement();
......@@ -83,7 +85,7 @@ public class TestBigResult extends TestBase {
}
}
private void testLimitBufferedResult() throws Exception {
private void testLimitBufferedResult() throws SQLException {
deleteDb("bigResult");
Connection conn = getConnection("bigResult");
Statement stat = conn.createStatement();
......@@ -109,7 +111,7 @@ public class TestBigResult extends TestBase {
conn.close();
}
private void testOrderGroup() throws Exception {
private void testOrderGroup() throws SQLException {
deleteDb("bigResult");
Connection conn = getConnection("bigResult");
Statement stat = conn.createStatement();
......
......@@ -57,7 +57,7 @@ public class TestCases extends TestBase {
testCollation();
}
private void testInvalidDatabaseName() throws Exception {
private void testInvalidDatabaseName() throws SQLException {
if (config.memory) {
return;
}
......@@ -75,7 +75,7 @@ public class TestCases extends TestBase {
}
}
private void testReuseSpace() throws Exception {
private void testReuseSpace() throws SQLException {
deleteDb("cases");
Connection conn = getConnection("cases");
Statement stat = conn.createStatement();
......@@ -99,7 +99,7 @@ public class TestCases extends TestBase {
conn.close();
}
private void testDeleteGroup() throws Exception {
private void testDeleteGroup() throws SQLException {
deleteDb("cases");
Connection conn = getConnection("cases");
Statement stat = conn.createStatement();
......@@ -110,7 +110,7 @@ public class TestCases extends TestBase {
conn.close();
}
private void testSpecialSQL() throws Exception {
private void testSpecialSQL() throws SQLException {
deleteDb("cases");
Connection conn = getConnection("cases");
Statement stat = conn.createStatement();
......@@ -138,7 +138,7 @@ public class TestCases extends TestBase {
conn.close();
}
private void testUpperCaseLowerCaseDatabase() throws Exception {
private void testUpperCaseLowerCaseDatabase() throws SQLException {
if (File.separatorChar != '\\') {
return;
}
......@@ -175,7 +175,7 @@ public class TestCases extends TestBase {
}
private void testManualCommitSet() throws Exception {
private void testManualCommitSet() throws SQLException {
deleteDb("cases");
Connection conn = getConnection("cases");
Connection conn2 = getConnection("cases");
......@@ -187,7 +187,7 @@ public class TestCases extends TestBase {
conn2.close();
}
private void testSchemaIdentityReconnect() throws Exception {
private void testSchemaIdentityReconnect() throws SQLException {
deleteDb("cases");
Connection conn = getConnection("cases");
Statement stat = conn.createStatement();
......@@ -246,7 +246,7 @@ public class TestCases extends TestBase {
deleteDb("cases");
}
private void testExecuteTrace() throws Exception {
private void testExecuteTrace() throws SQLException {
deleteDb("cases");
Connection conn = getConnection("cases");
Statement stat = conn.createStatement();
......@@ -265,7 +265,7 @@ public class TestCases extends TestBase {
conn.close();
}
private void testAlterTableReconnect() throws Exception {
private void testAlterTableReconnect() throws SQLException {
deleteDb("cases");
Connection conn = getConnection("cases");
Statement stat = conn.createStatement();
......@@ -313,7 +313,7 @@ public class TestCases extends TestBase {
conn.close();
}
private void testCollation() throws Exception {
private void testCollation() throws SQLException {
deleteDb("cases");
Connection conn = getConnection("cases");
Statement stat = conn.createStatement();
......@@ -339,7 +339,7 @@ public class TestCases extends TestBase {
conn.close();
}
private void testPersistentSettings() throws Exception {
private void testPersistentSettings() throws SQLException {
deleteDb("cases");
Connection conn = getConnection("cases");
Statement stat = conn.createStatement();
......@@ -360,7 +360,7 @@ public class TestCases extends TestBase {
conn.close();
}
private void testInsertSelectUnion() throws Exception {
private void testInsertSelectUnion() throws SQLException {
deleteDb("cases");
Connection conn = getConnection("cases");
Statement stat = conn.createStatement();
......@@ -387,7 +387,7 @@ public class TestCases extends TestBase {
conn.close();
}
private void testViewReconnect() throws Exception {
private void testViewReconnect() throws SQLException {
trace("testViewReconnect");
deleteDb("cases");
Connection conn = getConnection("cases");
......@@ -407,7 +407,7 @@ public class TestCases extends TestBase {
conn.close();
}
private void testDefaultQueryReconnect() throws Exception {
private void testDefaultQueryReconnect() throws SQLException {
trace("testDefaultQueryReconnect");
deleteDb("cases");
Connection conn = getConnection("cases");
......@@ -429,7 +429,7 @@ public class TestCases extends TestBase {
conn.close();
}
private void testBigString() throws Exception {
private void testBigString() throws SQLException {
trace("testBigString");
deleteDb("cases");
Connection conn = getConnection("cases");
......@@ -481,7 +481,7 @@ public class TestCases extends TestBase {
conn.close();
}
private void testConstraintReconnect() throws Exception {
private void testConstraintReconnect() throws SQLException {
trace("testConstraintReconnect");
deleteDb("cases");
Connection conn = getConnection("cases");
......@@ -500,7 +500,7 @@ public class TestCases extends TestBase {
conn.close();
}
private void testDoubleRecovery() throws Exception {
private void testDoubleRecovery() throws SQLException {
if (config.networked) {
return;
}
......@@ -535,7 +535,7 @@ public class TestCases extends TestBase {
conn.close();
}
private void testRenameReconnect() throws Exception {
private void testRenameReconnect() throws SQLException {
trace("testRenameReconnect");
deleteDb("cases");
Connection conn = getConnection("cases");
......@@ -562,7 +562,7 @@ public class TestCases extends TestBase {
conn.close();
}
private void testAllSizes() throws Exception {
private void testAllSizes() throws SQLException {
trace("testAllSizes");
deleteDb("cases");
Connection conn = getConnection("cases");
......@@ -594,7 +594,7 @@ public class TestCases extends TestBase {
conn.close();
}
private void testSelectForUpdate() throws Exception {
private void testSelectForUpdate() throws SQLException {
trace("testSelectForUpdate");
deleteDb("cases");
Connection conn1 = getConnection("cases");
......@@ -617,7 +617,7 @@ public class TestCases extends TestBase {
conn2.close();
}
private void testMutableObjects() throws Exception {
private void testMutableObjects() throws SQLException {
trace("testMutableObjects");
deleteDb("cases");
Connection conn = getConnection("cases");
......@@ -644,7 +644,7 @@ public class TestCases extends TestBase {
conn.close();
}
private void testCreateDrop() throws Exception {
private void testCreateDrop() throws SQLException {
trace("testCreateDrop");
deleteDb("cases");
Connection conn = getConnection("cases");
......@@ -658,7 +658,7 @@ public class TestCases extends TestBase {
conn.close();
}
private void testPolePos() throws Exception {
private void testPolePos() throws SQLException {
trace("testPolePos");
// poleposition-0.20
......@@ -732,7 +732,7 @@ public class TestCases extends TestBase {
c0.close();
}
private void testQuick() throws Exception {
private void testQuick() throws SQLException {
trace("testQuick");
deleteDb("cases");
......
......@@ -7,6 +7,7 @@
package org.h2.test.db;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import org.h2.test.TestBase;
......@@ -16,7 +17,7 @@ import org.h2.test.TestBase;
*/
public class TestCheckpoint extends TestBase {
public void test() throws Exception {
public void test() throws SQLException {
// TODO test checkpoint with rollback, not only just run the command
deleteDb("checkpoint");
Connection c0 = getConnection("checkpoint");
......
......@@ -23,7 +23,7 @@ import org.h2.tools.Server;
*/
public class TestCluster extends TestBase {
public void test() throws Exception {
public void test() throws SQLException {
if (config.memory || config.networked) {
return;
}
......@@ -33,7 +33,7 @@ public class TestCluster extends TestBase {
// create the master database
Connection conn;
Class.forName("org.h2.Driver");
org.h2.Driver.load();
conn = DriverManager.getConnection("jdbc:h2:file:" + baseDir + "/node1/test", "sa", "");
Statement stat;
stat = conn.createStatement();
......@@ -124,7 +124,7 @@ public class TestCluster extends TestBase {
n2.stop();
}
private void check(Connection conn, int len) throws Exception {
private void check(Connection conn, int len) throws SQLException {
PreparedStatement prep = conn.prepareStatement("SELECT * FROM TEST WHERE ID=?");
for (int i = 0; i < len; i++) {
prep.setInt(1, i);
......
......@@ -20,7 +20,7 @@ public class TestCompatibility extends TestBase {
private Connection conn;
public void test() throws Exception {
public void test() throws SQLException {
deleteDb("compatibility");
conn = getConnection("compatibility");
......@@ -33,7 +33,7 @@ public class TestCompatibility extends TestBase {
}
private void testUniqueIndexSingleNull() throws Exception {
private void testUniqueIndexSingleNull() throws SQLException {
Statement stat = conn.createStatement();
String[] modes = new String[] { "PostgreSQL", "MySQL", "HSQLDB", "MSSQLServer", "Derby", "Oracle", "Regular" };
String multiNull = "PostgreSQL,MySQL,Oracle,Regular";
......@@ -52,7 +52,7 @@ public class TestCompatibility extends TestBase {
}
}
private void testUniqueIndexOracle() throws Exception {
private void testUniqueIndexOracle() throws SQLException {
Statement stat = conn.createStatement();
stat.execute("SET MODE ORACLE");
stat.execute("create table t2(c1 int, c2 int)");
......@@ -76,7 +76,7 @@ public class TestCompatibility extends TestBase {
stat.execute("DROP TABLE T2");
}
private void testHsqlDb() throws Exception {
private void testHsqlDb() throws SQLException {
Statement stat = conn.createStatement();
stat.execute("DROP TABLE TEST IF EXISTS; CREATE TABLE TEST(ID INT PRIMARY KEY); ");
stat.execute("CALL CURRENT_TIME");
......@@ -95,7 +95,7 @@ public class TestCompatibility extends TestBase {
}
private void testMySQL() throws Exception {
private void testMySQL() throws SQLException {
Statement stat = conn.createStatement();
stat.execute("SELECT 1");
stat.execute("DROP TABLE IF EXISTS TEST");
......
......@@ -13,6 +13,7 @@ import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Random;
......@@ -44,7 +45,7 @@ public class TestCsv extends TestBase {
testPipe();
}
private void testSpaceSeparated() throws Exception {
private void testSpaceSeparated() throws SQLException {
deleteDb("csv");
File f = new File(baseDir + "/testSpace.csv");
FileUtils.delete(f.getAbsolutePath());
......@@ -107,7 +108,7 @@ public class TestCsv extends TestBase {
FileUtils.delete(f.getAbsolutePath());
}
private void testRandomData() throws Exception {
private void testRandomData() throws SQLException {
deleteDb("csv");
Connection conn = getConnection("csv");
Statement stat = conn.createStatement();
......@@ -204,7 +205,7 @@ public class TestCsv extends TestBase {
conn.close();
}
private void testPipe() throws Exception {
private void testPipe() throws SQLException {
deleteDb("csv");
Connection conn = getConnection("csv");
Statement stat = conn.createStatement();
......@@ -226,7 +227,7 @@ public class TestCsv extends TestBase {
conn.close();
}
private void testAsTable() throws Exception {
private void testAsTable() throws SQLException {
deleteDb("csv");
Connection conn = getConnection("csv");
Statement stat = conn.createStatement();
......@@ -288,7 +289,7 @@ public class TestCsv extends TestBase {
// 201,2,0,18
}
private void testWriteRead() throws Exception {
private void testWriteRead() throws SQLException {
deleteDb("csv");
......
......@@ -42,7 +42,7 @@ public class TestDeadlock extends TestBase {
testNoDeadlock();
}
private void initTest() throws Exception {
private void initTest() throws SQLException {
c1 = getConnection("deadlock");
c2 = getConnection("deadlock");
c3 = getConnection("deadlock");
......@@ -239,7 +239,7 @@ public class TestDeadlock extends TestBase {
end();
}
private void checkDeadlock() throws Exception {
private void checkDeadlock() throws SQLException {
assertTrue(lastException != null);
assertKnownException(lastException);
assertEquals(ErrorCode.DEADLOCK_1, lastException.getErrorCode());
......
......@@ -18,7 +18,7 @@ import org.h2.test.TestBase;
*/
public class TestEncryptedDb extends TestBase {
public void test() throws Exception {
public void test() throws SQLException {
if (config.memory || config.cipher != null) {
return;
}
......
......@@ -9,6 +9,7 @@ package org.h2.test.db;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.StringTokenizer;
......@@ -20,7 +21,7 @@ import org.h2.test.TestBase;
*/
public class TestFullText extends TestBase {
public void test() throws Exception {
public void test() throws SQLException {
if (config.memory) {
return;
}
......@@ -45,7 +46,7 @@ public class TestFullText extends TestBase {
}
private void testReopen(boolean lucene) throws Exception {
private void testReopen(boolean lucene) throws SQLException {
String prefix = lucene ? "FTL" : "FT";
deleteDb("fullTextReopen");
FileSystem.getInstance(baseDir).deleteRecursive(baseDir + "/fullTextReopen");
......@@ -66,7 +67,7 @@ public class TestFullText extends TestBase {
conn.close();
}
private void testPerformance(boolean lucene) throws Exception {
private void testPerformance(boolean lucene) throws SQLException {
deleteDb("fullText");
FileSystem.getInstance(baseDir).deleteRecursive(baseDir + "/fullText");
Connection conn = getConnection("fullText");
......@@ -107,7 +108,7 @@ public class TestFullText extends TestBase {
conn.close();
}
private void test(boolean lucene, String dataType) throws Exception {
private void test(boolean lucene, String dataType) throws SQLException {
deleteDb("fullText");
Connection conn = getConnection("fullText");
String prefix = lucene ? "FTL_" : "FT_";
......
......@@ -25,7 +25,7 @@ public class TestFunctionOverload extends TestBase {
private Connection conn;
private DatabaseMetaData meta;
public void test() throws Exception {
public void test() throws SQLException {
this.deleteDb("functionOverload");
conn = getConnection("functionOverload");
meta = conn.getMetaData();
......@@ -37,7 +37,7 @@ public class TestFunctionOverload extends TestBase {
conn.close();
}
private void testOverloadError() throws Exception {
private void testOverloadError() throws SQLException {
Statement stat = conn.createStatement();
try {
stat.execute("create alias overloadError for \"" + ME + ".overloadError\"");
......@@ -47,7 +47,7 @@ public class TestFunctionOverload extends TestBase {
}
}
private void testControl() throws Exception {
private void testControl() throws SQLException {
Statement stat = conn.createStatement();
stat.execute("create alias overload0 for \"" + ME + ".overload0\"");
ResultSet rs = stat.executeQuery("select overload0() from dual");
......@@ -59,7 +59,7 @@ public class TestFunctionOverload extends TestBase {
assertFalse(rs.next());
}
private void testOverload() throws Exception {
private void testOverload() throws SQLException {
Statement stat = conn.createStatement();
stat.execute("create alias overload1or2 for \"" + ME + ".overload1or2\"");
ResultSet rs = stat.executeQuery("select overload1or2(1) from dual");
......@@ -78,7 +78,7 @@ public class TestFunctionOverload extends TestBase {
assertFalse(rs.next());
}
private void testOverloadNamedArgs() throws Exception {
private void testOverloadNamedArgs() throws SQLException {
Statement stat = conn.createStatement();
stat.execute("create alias overload1or2Named for \"" + ME + ".overload1or2(int)\"");
......@@ -100,7 +100,7 @@ public class TestFunctionOverload extends TestBase {
stat.close();
}
private void testOverloadWithConnection() throws Exception {
private void testOverloadWithConnection() throws SQLException {
Statement stat = conn.createStatement();
stat.execute("create alias overload1or2WithConn for \"" + ME + ".overload1or2WithConn\"");
......
......@@ -39,7 +39,7 @@ public class TestFunctions extends TestBase {
testFileRead();
}
private void testVarArgs() throws Exception {
private void testVarArgs() throws SQLException {
//## Java 1.5 begin ##
Connection conn = getConnection("functions");
Statement stat = conn.createStatement();
......@@ -127,7 +127,7 @@ public class TestFunctions extends TestBase {
}
private void testAggregate() throws Exception {
private void testAggregate() throws SQLException {
deleteDb("functions");
Connection conn = getConnection("functions");
Statement stat = conn.createStatement();
......@@ -163,7 +163,7 @@ public class TestFunctions extends TestBase {
conn.close();
}
private void testFunctions() throws Exception {
private void testFunctions() throws SQLException {
deleteDb("functions");
Connection conn = getConnection("functions");
Statement stat = conn.createStatement();
......@@ -298,7 +298,7 @@ public class TestFunctions extends TestBase {
conn.close();
}
private void test(Statement stat, String sql, String value) throws Exception {
private void test(Statement stat, String sql, String value) throws SQLException {
ResultSet rs = stat.executeQuery("CALL " + sql);
rs.next();
String s = rs.getString(1);
......
......@@ -9,6 +9,7 @@ package org.h2.test.db;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Random;
......@@ -24,7 +25,7 @@ public class TestIndex extends TestBase {
private Statement stat;
private Random random = new Random();
public void test() throws Exception {
public void test() throws SQLException {
testDescIndex();
testHashIndex();
......@@ -70,7 +71,7 @@ public class TestIndex extends TestBase {
conn.close();
}
private void testHashIndex() throws Exception {
private void testHashIndex() throws SQLException {
reconnect();
stat.execute("create table testA(id int primary key, name varchar)");
stat.execute("create table testB(id int primary key hash, name varchar)");
......@@ -110,7 +111,7 @@ public class TestIndex extends TestBase {
conn.close();
}
private void reconnect() throws Exception {
private void reconnect() throws SQLException {
if (conn != null) {
conn.close();
conn = null;
......@@ -119,7 +120,7 @@ public class TestIndex extends TestBase {
stat = conn.createStatement();
}
private void testDescIndex() throws Exception {
private void testDescIndex() throws SQLException {
if (config.memory) {
return;
}
......@@ -155,7 +156,7 @@ public class TestIndex extends TestBase {
return buff.toString();
}
private void testWideIndex(int length) throws Exception {
private void testWideIndex(int length) throws SQLException {
reconnect();
stat.execute("CREATE TABLE TEST(ID INT, NAME VARCHAR)");
stat.execute("CREATE INDEX IDXNAME ON TEST(NAME)");
......@@ -180,7 +181,7 @@ public class TestIndex extends TestBase {
stat.execute("DROP TABLE TEST");
}
private void testLike() throws Exception {
private void testLike() throws SQLException {
reconnect();
stat.execute("CREATE TABLE ABC(ID INT, NAME VARCHAR)");
stat.execute("INSERT INTO ABC VALUES(1, 'Hello')");
......@@ -190,7 +191,7 @@ public class TestIndex extends TestBase {
stat.execute("DROP TABLE ABC");
}
private void testConstraint() throws Exception {
private void testConstraint() throws SQLException {
if (config.memory) {
return;
}
......@@ -201,7 +202,7 @@ public class TestIndex extends TestBase {
stat.execute("DROP TABLE CHILD");
}
private void testLargeIndex() throws Exception {
private void testLargeIndex() throws SQLException {
random.setSeed(10);
for (int i = 1; i < 100; i += getSize(1000, 3)) {
stat.execute("DROP TABLE IF EXISTS TEST");
......@@ -226,7 +227,7 @@ public class TestIndex extends TestBase {
stat.execute("DROP TABLE IF EXISTS TEST");
}
private void testHashIndex(boolean primaryKey, boolean hash) throws Exception {
private void testHashIndex(boolean primaryKey, boolean hash) throws SQLException {
if (config.memory) {
return;
}
......@@ -264,7 +265,7 @@ public class TestIndex extends TestBase {
assertEquals(0, getValue(stat, "SELECT COUNT(*) FROM TEST"));
}
private void testMultiColumnIndex() throws Exception {
private void testMultiColumnIndex() throws SQLException {
stat.execute("DROP TABLE IF EXISTS TEST");
stat.execute("CREATE TABLE TEST(A INT, B INT)");
PreparedStatement prep;
......@@ -288,7 +289,7 @@ public class TestIndex extends TestBase {
assertEquals(0, getValue(stat, "SELECT COUNT(*) FROM TEST"));
}
private void testMultiColumnHashIndex() throws Exception {
private void testMultiColumnHashIndex() throws SQLException {
if (config.memory) {
return;
}
......@@ -329,13 +330,13 @@ public class TestIndex extends TestBase {
stat.execute("DROP TABLE TEST");
}
private int getValue(Statement stat, String sql) throws Exception {
private int getValue(Statement stat, String sql) throws SQLException {
ResultSet rs = stat.executeQuery(sql);
rs.next();
return rs.getInt(1);
}
private void log(Statement stat, String sql) throws Exception {
private void log(Statement stat, String sql) throws SQLException {
trace(sql);
ResultSet rs = stat.executeQuery(sql);
int cols = rs.getMetaData().getColumnCount();
......
......@@ -22,7 +22,7 @@ import org.h2.test.TestBase;
*/
public class TestLinkedTable extends TestBase {
public void test() throws Exception {
public void test() throws SQLException {
// testLinkAutoAdd();
testReadOnlyLinkedTable();
testLinkOtherSchema();
......@@ -34,7 +34,7 @@ public class TestLinkedTable extends TestBase {
}
// this is not a bug, it is the documented behavior
// private void testLinkAutoAdd() throws Exception {
// private void testLinkAutoAdd() throws SQLException {
// Class.forName("org.h2.Driver");
// Connection ca =
// DriverManager.getConnection("jdbc:h2:mem:one", "sa", "sa");
......@@ -53,8 +53,8 @@ public class TestLinkedTable extends TestBase {
// cb.close();
// }
private void testReadOnlyLinkedTable() throws Exception {
Class.forName("org.h2.Driver");
private void testReadOnlyLinkedTable() throws SQLException {
org.h2.Driver.load();
Connection ca = DriverManager.getConnection("jdbc:h2:mem:one", "sa", "sa");
Connection cb = DriverManager.getConnection("jdbc:h2:mem:two", "sa", "sa");
Statement sa = ca.createStatement();
......@@ -87,8 +87,8 @@ public class TestLinkedTable extends TestBase {
cb.close();
}
private void testLinkOtherSchema() throws Exception {
Class.forName("org.h2.Driver");
private void testLinkOtherSchema() throws SQLException {
org.h2.Driver.load();
Connection ca = DriverManager.getConnection("jdbc:h2:mem:one", "sa", "sa");
Connection cb = DriverManager.getConnection("jdbc:h2:mem:two", "sa", "sa");
Statement sa = ca.createStatement();
......@@ -106,8 +106,8 @@ public class TestLinkedTable extends TestBase {
cb.close();
}
private void testLinkTwoTables() throws Exception {
Class.forName("org.h2.Driver");
private void testLinkTwoTables() throws SQLException {
org.h2.Driver.load();
Connection conn = DriverManager.getConnection("jdbc:h2:mem:one", "sa", "sa");
Statement stat = conn.createStatement();
stat.execute("CREATE SCHEMA Y");
......@@ -129,8 +129,8 @@ public class TestLinkedTable extends TestBase {
conn2.close();
}
private void testLinkDrop() throws Exception {
Class.forName("org.h2.Driver");
private void testLinkDrop() throws SQLException {
org.h2.Driver.load();
Connection connA = DriverManager.getConnection("jdbc:h2:mem:a");
Statement statA = connA.createStatement();
statA.execute("CREATE TABLE TEST(ID INT)");
......@@ -150,10 +150,10 @@ public class TestLinkedTable extends TestBase {
connB.close();
}
private void testLinkEmitUpdates() throws Exception {
private void testLinkEmitUpdates() throws SQLException {
deleteDb("linked1");
deleteDb("linked2");
Class.forName("org.h2.Driver");
org.h2.Driver.load();
Connection conn = DriverManager.getConnection("jdbc:h2:" + baseDir + "/linked1", "sa1", "abc");
Statement stat = conn.createStatement();
......@@ -209,10 +209,10 @@ public class TestLinkedTable extends TestBase {
conn2.close();
}
private void testLinkSchema() throws Exception {
private void testLinkSchema() throws SQLException {
deleteDb("linked1");
deleteDb("linked2");
Class.forName("org.h2.Driver");
org.h2.Driver.load();
Connection conn = DriverManager.getConnection("jdbc:h2:" + baseDir + "/linked1", "sa1", "abc");
Statement stat = conn.createStatement();
......@@ -233,10 +233,10 @@ public class TestLinkedTable extends TestBase {
conn2.close();
}
private void testLinkTable() throws Exception {
private void testLinkTable() throws SQLException {
deleteDb("linked1");
deleteDb("linked2");
Class.forName("org.h2.Driver");
org.h2.Driver.load();
Connection conn = DriverManager.getConnection("jdbc:h2:" + baseDir + "/linked1", "sa1", "abc");
Statement stat = conn.createStatement();
......@@ -338,7 +338,7 @@ public class TestLinkedTable extends TestBase {
deleteDb("linked2");
}
private void testRow(Statement stat, String name) throws Exception {
private void testRow(Statement stat, String name) throws SQLException {
ResultSet rs = stat.executeQuery("SELECT * FROM " + name + " WHERE ID=1");
rs.next();
assertEquals(rs.getString("NAME"), "Hello");
......
......@@ -29,7 +29,7 @@ public class TestListener extends TestBase implements DatabaseEventListener {
start = last = System.currentTimeMillis();
}
public void test() throws Exception {
public void test() throws SQLException {
if (config.networked) {
return;
}
......
......@@ -8,6 +8,7 @@ package org.h2.test.db;
import java.io.ByteArrayInputStream;
import java.io.CharArrayReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.io.StringReader;
......@@ -61,7 +62,7 @@ public class TestLob extends TestBase {
testJavaObject();
}
private void testLobServerMemory() throws Exception {
private void testLobServerMemory() throws SQLException {
deleteDb("lob");
Connection conn = getConnection("lob");
Statement stat = conn.createStatement();
......@@ -73,7 +74,7 @@ public class TestLob extends TestBase {
conn.close();
}
private void testLobDelete() throws Exception {
private void testLobDelete() throws SQLException {
if (config.memory) {
return;
}
......@@ -104,7 +105,7 @@ public class TestLob extends TestBase {
conn.close();
}
private void testLobVariable() throws Exception {
private void testLobVariable() throws SQLException {
deleteDb("lob");
Connection conn = reconnect(null);
Statement stat = conn.createStatement();
......@@ -121,7 +122,7 @@ public class TestLob extends TestBase {
conn.close();
}
private void testLobDrop() throws Exception {
private void testLobDrop() throws SQLException {
if (config.logMode == 0 || config.networked) {
return;
}
......@@ -193,7 +194,7 @@ public class TestLob extends TestBase {
conn.close();
}
private void testLobTransactions(int spaceLen) throws Exception {
private void testLobTransactions(int spaceLen) throws SQLException {
if (config.logMode == 0) {
return;
}
......@@ -277,7 +278,7 @@ public class TestLob extends TestBase {
conn.close();
}
private void testLobRollbackStop() throws Exception {
private void testLobRollbackStop() throws SQLException {
if (config.logMode == 0) {
return;
}
......@@ -297,7 +298,7 @@ public class TestLob extends TestBase {
conn.close();
}
private void testLobCopy() throws Exception {
private void testLobCopy() throws SQLException {
deleteDb("lob");
Connection conn = reconnect(null);
Statement stat = conn.createStatement();
......@@ -403,7 +404,7 @@ public class TestLob extends TestBase {
conn0.close();
}
private void testLobCopy(boolean compress) throws Exception {
private void testLobCopy(boolean compress) throws SQLException {
deleteDb("lob");
Connection conn;
conn = reconnect(null);
......@@ -582,7 +583,7 @@ public class TestLob extends TestBase {
conn.close();
}
private Connection reconnect(Connection conn) throws Exception {
private Connection reconnect(Connection conn) throws SQLException {
long time = System.currentTimeMillis();
if (conn != null) {
conn.close();
......@@ -592,7 +593,7 @@ public class TestLob extends TestBase {
return conn;
}
private void testUpdateLob() throws Exception {
private void testUpdateLob() throws SQLException {
deleteDb("lob");
Connection conn;
conn = reconnect(null);
......@@ -757,7 +758,7 @@ public class TestLob extends TestBase {
conn.close();
}
private void testJavaObject() throws Exception {
private void testJavaObject() throws SQLException {
deleteDb("lob");
Connection conn = getConnection("lob");
conn.createStatement().execute("CREATE TABLE TEST(ID INT PRIMARY KEY, DATA OTHER)");
......@@ -776,7 +777,7 @@ public class TestLob extends TestBase {
conn.close();
}
private void checkStream(InputStream a, InputStream b, int len) throws Exception {
private void checkStream(InputStream a, InputStream b, int len) throws IOException {
// this doesn't actually read anything - just tests reading 0 bytes
a.read(new byte[0]);
b.read(new byte[0]);
......@@ -800,7 +801,7 @@ public class TestLob extends TestBase {
b.close();
}
private void checkReader(Reader a, Reader b, int len) throws Exception {
private void checkReader(Reader a, Reader b, int len) throws IOException {
for (int i = 0; len < 0 || i < len; i++) {
int ca = a.read();
int cb = b.read();
......
......@@ -9,6 +9,7 @@ package org.h2.test.db;
import java.io.File;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
......@@ -24,7 +25,7 @@ public class TestLogFile extends TestBase {
private static final int MAX_LOG_SIZE = 1;
private Connection conn;
private long reconnect(int maxFiles) throws Exception {
private long reconnect(int maxFiles) throws SQLException {
if (conn != null) {
conn.close();
}
......@@ -40,7 +41,7 @@ public class TestLogFile extends TestBase {
return length;
}
public void test() throws Exception {
public void test() throws SQLException {
if (config.memory) {
return;
}
......@@ -65,7 +66,7 @@ public class TestLogFile extends TestBase {
}
}
private void checkLogSize() throws Exception {
private void checkLogSize() throws SQLException {
String[] files = new File(".").list();
for (int j = 0; j < files.length; j++) {
String name = files[j];
......@@ -76,7 +77,7 @@ public class TestLogFile extends TestBase {
}
}
private void insert() throws Exception {
private void insert() throws SQLException {
Statement stat = conn.createStatement();
stat.execute("SET LOGSIZE 200");
stat.execute("SET MAX_LOG_SIZE " + MAX_LOG_SIZE);
......
......@@ -9,6 +9,7 @@ package org.h2.test.db;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Random;
......@@ -22,7 +23,7 @@ public class TestMemoryUsage extends TestBase {
private Connection conn;
private void reconnect() throws Exception {
private void reconnect() throws SQLException {
if (conn != null) {
conn.close();
}
......@@ -31,7 +32,7 @@ public class TestMemoryUsage extends TestBase {
conn = getConnection("memoryUsage");
}
public void test() throws Exception {
public void test() throws SQLException {
deleteDb("memoryUsage");
testCreateIndex();
testClob();
......@@ -45,7 +46,7 @@ public class TestMemoryUsage extends TestBase {
conn.close();
}
private void testClob() throws Exception {
private void testClob() throws SQLException {
if (config.memory || !config.big) {
return;
}
......@@ -69,7 +70,7 @@ public class TestMemoryUsage extends TestBase {
conn.close();
}
private void testCreateIndex() throws Exception {
private void testCreateIndex() throws SQLException {
if (config.memory) {
return;
}
......@@ -95,7 +96,7 @@ public class TestMemoryUsage extends TestBase {
conn.close();
}
private void testReconnectOften() throws Exception {
private void testReconnectOften() throws SQLException {
int len = getSize(1, 2000);
Connection conn1 = getConnection("memoryUsage");
printTimeMemory("start", 0);
......@@ -111,7 +112,7 @@ public class TestMemoryUsage extends TestBase {
conn1.close();
}
private void insertUpdateSelectDelete() throws Exception {
private void insertUpdateSelectDelete() throws SQLException {
Statement stat = conn.createStatement();
long time;
int len = getSize(1, 2000);
......
......@@ -166,7 +166,7 @@ public class TestMultiConn extends TestBase implements DatabaseEventListener {
// do nothing
}
private void testCommitRollback() throws Exception {
private void testCommitRollback() throws SQLException {
deleteDb("multiConn");
Connection c1 = getConnection("multiConn");
Connection c2 = getConnection("multiConn");
......
......@@ -9,6 +9,7 @@ package org.h2.test.db;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Random;
......@@ -20,7 +21,7 @@ import org.h2.tools.MultiDimension;
*/
public class TestMultiDimension extends TestBase {
public void test() throws Exception {
public void test() throws SQLException {
Random rand = new Random(10);
for (int i = 0; i < 1000; i++) {
int x = rand.nextInt(1000), y = rand.nextInt(1000), z = rand.nextInt(1000);
......
......@@ -9,6 +9,7 @@ package org.h2.test.db;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Random;
......@@ -30,7 +31,7 @@ public class TestMultiThread extends TestBase implements Runnable {
// nothing to do
}
private TestMultiThread(TestAll config, TestMultiThread parent) throws Exception {
private TestMultiThread(TestAll config, TestMultiThread parent) throws SQLException {
this.config = config;
this.parent = parent;
random = new Random();
......@@ -63,7 +64,7 @@ public class TestMultiThread extends TestBase implements Runnable {
conn.close();
}
private Connection getConnection() throws Exception {
private Connection getConnection() throws SQLException {
return getConnection("jdbc:h2:mem:multiThread");
}
......
......@@ -48,7 +48,7 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener {
conn.close();
}
private void testBackup(boolean encrypt) throws Exception {
private void testBackup(boolean encrypt) throws SQLException {
deleteDb(baseDir, "openClose");
String url;
if (encrypt) {
......@@ -74,7 +74,7 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener {
conn.close();
}
private void testReconnectFast() throws Exception {
private void testReconnectFast() throws SQLException {
deleteDb(baseDir, "openClose");
String url = "jdbc:h2:" + baseDir + "/openClose;DATABASE_EVENT_LISTENER='" + TestOpenClose.class.getName()
+ "'";
......@@ -108,7 +108,7 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener {
}
private void testCase() throws Exception {
Class.forName("org.h2.Driver");
org.h2.Driver.load();
deleteDb(baseDir, "openClose");
final String url = "jdbc:h2:" + baseDir + "/openClose;FILE_LOCK=NO";
Connection conn = DriverManager.getConnection(url, "sa", "");
......
......@@ -9,6 +9,7 @@ package org.h2.test.db;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.HashMap;
......@@ -41,7 +42,7 @@ public class TestOptimizations extends TestBase {
testMinMaxCountOptimization(false);
}
private void testOptimizeInJoin() throws Exception {
private void testOptimizeInJoin() throws SQLException {
boolean old = SysProperties.optimizeInJoin;
SysProperties.optimizeInJoin = true;
......@@ -62,7 +63,7 @@ public class TestOptimizations extends TestBase {
SysProperties.optimizeInJoin = old;
}
private void testMinMaxNullOptimization() throws Exception {
private void testMinMaxNullOptimization() throws SQLException {
deleteDb("optimizations");
Connection conn = getConnection("optimizations");
Statement stat = conn.createStatement();
......@@ -119,7 +120,7 @@ public class TestOptimizations extends TestBase {
conn.close();
}
private void testMultiColumnRangeQuery() throws Exception {
private void testMultiColumnRangeQuery() throws SQLException {
deleteDb("optimizations");
Connection conn = getConnection("optimizations");
Statement stat = conn.createStatement();
......@@ -135,7 +136,7 @@ public class TestOptimizations extends TestBase {
conn.close();
}
private void testDistinctOptimization() throws Exception {
private void testDistinctOptimization() throws SQLException {
deleteDb("optimizations");
Connection conn = getConnection("optimizations");
Statement stat = conn.createStatement();
......@@ -206,7 +207,7 @@ public class TestOptimizations extends TestBase {
conn.close();
}
private void testQueryCacheSpeed() throws Exception {
private void testQueryCacheSpeed() throws SQLException {
deleteDb("optimizations");
Connection conn = getConnection("optimizations");
Statement stat = conn.createStatement();
......@@ -220,7 +221,7 @@ public class TestOptimizations extends TestBase {
conn.close();
}
private void testQuerySpeed(Statement stat, String sql) throws Exception {
private void testQuerySpeed(Statement stat, String sql) throws SQLException {
stat.execute("set OPTIMIZE_REUSE_RESULTS 0");
stat.execute(sql);
long time = System.currentTimeMillis();
......@@ -236,7 +237,7 @@ public class TestOptimizations extends TestBase {
}
}
private void testQueryCache(boolean optimize) throws Exception {
private void testQueryCache(boolean optimize) throws SQLException {
deleteDb("optimizations");
Connection conn = getConnection("optimizations");
Statement stat = conn.createStatement();
......@@ -265,7 +266,7 @@ public class TestOptimizations extends TestBase {
conn.close();
}
private void testMinMaxCountOptimization(boolean memory) throws Exception {
private void testMinMaxCountOptimization(boolean memory) throws SQLException {
deleteDb("optimizations");
Connection conn = getConnection("optimizations");
Statement stat = conn.createStatement();
......@@ -340,7 +341,7 @@ public class TestOptimizations extends TestBase {
conn.close();
}
private void testIn() throws Exception {
private void testIn() throws SQLException {
deleteDb("optimizations");
Connection conn = getConnection("optimizations");
Statement stat = conn.createStatement();
......
......@@ -24,7 +24,7 @@ public class TestOutOfMemory extends TestBase {
private LinkedList list = new LinkedList();
public void test() throws Exception {
public void test() throws SQLException {
if (config.memory) {
return;
}
......
......@@ -33,7 +33,7 @@ public class TestPowerOff extends TestBase {
private int maxPowerOffCount;
public void test() throws Exception {
public void test() throws SQLException {
if (config.memory || config.logMode == 0) {
return;
}
......@@ -51,7 +51,7 @@ public class TestPowerOff extends TestBase {
testPersistentTables();
}
private void testSummaryCrash() throws Exception {
private void testSummaryCrash() throws SQLException {
if (config.networked) {
return;
}
......@@ -95,7 +95,7 @@ public class TestPowerOff extends TestBase {
conn.close();
}
private void testCrash() throws Exception {
private void testCrash() throws SQLException {
if (config.networked) {
return;
}
......@@ -135,7 +135,7 @@ public class TestPowerOff extends TestBase {
}
}
private void testShutdown() throws Exception {
private void testShutdown() throws SQLException {
deleteDb(dir, dbName);
Connection conn = getConnection(url);
Statement stat = conn.createStatement();
......@@ -152,7 +152,7 @@ public class TestPowerOff extends TestBase {
conn.close();
}
private void testNoIndexFile() throws Exception {
private void testNoIndexFile() throws SQLException {
if (config.networked) {
return;
}
......@@ -183,7 +183,7 @@ public class TestPowerOff extends TestBase {
conn.close();
}
private void testMemoryTables() throws Exception {
private void testMemoryTables() throws SQLException {
if (config.networked) {
return;
}
......@@ -213,7 +213,7 @@ public class TestPowerOff extends TestBase {
conn.close();
}
private void testPersistentTables() throws Exception {
private void testPersistentTables() throws SQLException {
if (config.networked) {
return;
}
......@@ -234,7 +234,7 @@ public class TestPowerOff extends TestBase {
recoverAndCheckConsistency();
}
private void runTest(int min, int max, boolean withConsistencyCheck) throws Exception {
private void runTest(int min, int max, boolean withConsistencyCheck) throws SQLException {
for (int i = min; i < max; i++) {
deleteDb(dir, dbName);
Database.setInitialPowerOffCount(i);
......@@ -249,7 +249,7 @@ public class TestPowerOff extends TestBase {
Database.setInitialPowerOffCount(0);
}
private int testRun(boolean init) throws Exception {
private int testRun(boolean init) throws SQLException {
if (init) {
Database.setInitialPowerOffCount(Integer.MAX_VALUE);
}
......@@ -289,7 +289,7 @@ public class TestPowerOff extends TestBase {
return state;
}
private int recoverAndCheckConsistency() throws Exception {
private int recoverAndCheckConsistency() throws SQLException {
int state;
Database.setInitialPowerOffCount(0);
Connection conn = getConnection(url);
......
......@@ -34,7 +34,7 @@ public class TestReadOnly extends TestBase {
}
}
private void testReadOnlyDbCreate() throws Exception {
private void testReadOnlyDbCreate() throws SQLException {
if (config.deleteIndex) {
return;
}
......
......@@ -21,14 +21,14 @@ public class TestRights extends TestBase {
private Statement stat;
public void test() throws Exception {
public void test() throws SQLException {
testDropTempTables();
// testLowerCaseUser();
testSchemaRenameUser();
testAccessRights();
}
// public void testLowerCaseUser() throws Exception {
// public void testLowerCaseUser() throws SQLException {
// Documentation: For compatibility,
// only unquoted or uppercase user names are allowed.
// deleteDb("rights");
......@@ -43,7 +43,7 @@ public class TestRights extends TestBase {
// conn.close();
// }
private void testDropTempTables() throws Exception {
private void testDropTempTables() throws SQLException {
deleteDb("rights");
Connection conn = getConnection("rights");
stat = conn.createStatement();
......@@ -65,7 +65,7 @@ public class TestRights extends TestBase {
conn.close();
}
private void testSchemaRenameUser() throws Exception {
private void testSchemaRenameUser() throws SQLException {
if (config.memory) {
return;
}
......@@ -98,7 +98,7 @@ public class TestRights extends TestBase {
conn.close();
}
private void testAccessRights() throws Exception {
private void testAccessRights() throws SQLException {
if (config.memory) {
return;
}
......@@ -236,7 +236,7 @@ public class TestRights extends TestBase {
conn.close();
}
private void testTableType(Connection conn, String type) throws Exception {
private void testTableType(Connection conn, String type) throws SQLException {
executeSuccess("SET DEFAULT_TABLE_TYPE " + type);
executeSuccess("CREATE TABLE TEST(ID INT)");
ResultSet rs = conn.createStatement().executeQuery(
......@@ -246,7 +246,7 @@ public class TestRights extends TestBase {
executeSuccess("DROP TABLE TEST");
}
private void executeError(String sql) throws Exception {
private void executeError(String sql) throws SQLException {
try {
stat.execute(sql);
fail("not admin");
......@@ -255,7 +255,7 @@ public class TestRights extends TestBase {
}
}
private void executeSuccess(String sql) throws Exception {
private void executeSuccess(String sql) throws SQLException {
if (stat.execute(sql)) {
ResultSet rs = stat.getResultSet();
......
......@@ -18,7 +18,7 @@ import org.h2.test.TestBase;
*/
public class TestRunscript extends TestBase implements Trigger {
public void test() throws Exception {
public void test() throws SQLException {
test(false);
test(true);
}
......@@ -33,7 +33,7 @@ public class TestRunscript extends TestBase implements Trigger {
return Math.abs(a);
}
private void test(boolean password) throws Exception {
private void test(boolean password) throws SQLException {
deleteDb("runscript");
Connection conn1, conn2;
Statement stat1, stat2;
......
......@@ -22,7 +22,7 @@ public class TestSQLInjection extends TestBase {
private Connection conn;
private Statement stat;
public void test() throws Exception {
public void test() throws SQLException {
deleteDb("sqlInjection");
reconnect("sqlInjection");
stat.execute("DROP TABLE IF EXISTS USERS");
......@@ -89,7 +89,7 @@ public class TestSQLInjection extends TestBase {
return rs.next();
}
private boolean checkPasswordSecure(String pwd) throws Exception {
private boolean checkPasswordSecure(String pwd) throws SQLException {
String sql = "SELECT * FROM USERS WHERE PASSWORD=?";
PreparedStatement prep = conn.prepareStatement(sql);
prep.setString(1, pwd);
......@@ -97,7 +97,7 @@ public class TestSQLInjection extends TestBase {
return rs.next();
}
private void reconnect(String name) throws Exception {
private void reconnect(String name) throws SQLException {
if (!config.memory) {
if (conn != null) {
conn.close();
......
......@@ -294,7 +294,7 @@ public class TestScript extends TestBase {
writeResult((ordered ? "rows (ordered): " : "rows: ") + i, null);
}
private String format(String[] row, int[] max) throws Exception {
private String format(String[] row, int[] max) throws SQLException {
int length = max.length;
StringBuffer buff = new StringBuffer();
for (int i = 0; i < length; i++) {
......@@ -351,7 +351,7 @@ public class TestScript extends TestBase {
}
private void write(String s) throws Exception {
private void write(String s) {
line++;
out.println(s);
}
......
......@@ -64,7 +64,7 @@ public class TestScriptSimple extends TestBase {
conn.close();
}
private void reconnect() throws Exception {
private void reconnect() throws SQLException {
if (conn != null) {
conn.close();
}
......
......@@ -8,6 +8,7 @@ package org.h2.test.db;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import org.h2.test.TestBase;
......@@ -17,14 +18,14 @@ import org.h2.test.TestBase;
*/
public class TestSequence extends TestBase {
public void test() throws Exception {
public void test() throws SQLException {
testAlterSequenceColumn();
testAlterSequence();
testCache();
testTwo();
}
private void testAlterSequenceColumn() throws Exception {
private void testAlterSequenceColumn() throws SQLException {
deleteDb("sequence");
Connection conn = getConnection("sequence");
Statement stat = conn.createStatement();
......@@ -36,7 +37,7 @@ public class TestSequence extends TestBase {
conn.close();
}
private void testAlterSequence() throws Exception {
private void testAlterSequence() throws SQLException {
deleteDb("sequence");
Connection conn = getConnection("sequence");
Statement stat = conn.createStatement();
......@@ -49,7 +50,7 @@ public class TestSequence extends TestBase {
conn.close();
}
private void testCache() throws Exception {
private void testCache() throws SQLException {
if (config.memory) {
return;
}
......@@ -74,7 +75,7 @@ public class TestSequence extends TestBase {
conn.close();
}
private void testTwo() throws Exception {
private void testTwo() throws SQLException {
deleteDb("sequence");
Connection conn = getConnection("sequence");
Statement stat = conn.createStatement();
......@@ -101,7 +102,7 @@ public class TestSequence extends TestBase {
conn.close();
}
private long getNext(Statement stat) throws Exception {
private long getNext(Statement stat) throws SQLException {
ResultSet rs = stat.executeQuery("call next value for testSequence");
rs.next();
long value = rs.getLong(1);
......
......@@ -26,7 +26,7 @@ public class TestSessionsLocks extends TestBase {
testLocks();
}
private void testLocks() throws Exception {
private void testLocks() throws SQLException {
deleteDb("sessionsLocks");
Connection conn = getConnection("sessionsLocks;MULTI_THREADED=1");
Statement stat = conn.createStatement();
......
......@@ -8,6 +8,7 @@ package org.h2.test.db;
import java.io.File;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import org.h2.test.TestBase;
......@@ -17,7 +18,7 @@ import org.h2.test.TestBase;
*/
public class TestSpaceReuse extends TestBase {
public void test() throws Exception {
public void test() throws SQLException {
if (config.memory) {
return;
}
......
......@@ -8,6 +8,7 @@ package org.h2.test.db;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;
import org.h2.test.TestBase;
......@@ -23,7 +24,7 @@ public class TestSpeed extends TestBase {
// TODO test: here is more code, currently untested!
public void test() throws Exception {
public void test() throws SQLException {
deleteDb("speed");
Connection conn;
......@@ -157,7 +158,7 @@ public class TestSpeed extends TestBase {
trace(time + " close");
}
// private void testOuterJoin() throws Exception {
// private void testOuterJoin() throws SQLException {
// Class.forName("org.h2.jdbc.jdbcDriver");
// Connection conn = DriverManager.getConnection("jdbc:h2:test");
......
......@@ -18,7 +18,7 @@ import org.h2.test.TestBase;
*/
public class TestTempTables extends TestBase {
public void test() throws Exception {
public void test() throws SQLException {
deleteDb("tempTables");
Connection c1 = getConnection("tempTables");
Connection c2 = getConnection("tempTables");
......
......@@ -23,14 +23,14 @@ import org.h2.test.TestBase;
*/
public class TestTransaction extends TestBase {
public void test() throws Exception {
public void test() throws SQLException {
testSetTransaction();
testReferential();
testSavepoint();
testIsolation();
}
private void testSetTransaction() throws Exception {
private void testSetTransaction() throws SQLException {
deleteDb("transaction");
Connection conn = getConnection("transaction");
conn.setAutoCommit(false);
......@@ -51,7 +51,7 @@ public class TestTransaction extends TestBase {
conn.close();
}
private void testReferential() throws Exception {
private void testReferential() throws SQLException {
deleteDb("transaction");
Connection c1 = getConnection("transaction");
c1.setAutoCommit(false);
......@@ -76,7 +76,7 @@ public class TestTransaction extends TestBase {
c2.close();
}
private void testSavepoint() throws Exception {
private void testSavepoint() throws SQLException {
deleteDb("transaction");
Connection conn = getConnection("transaction");
Statement stat = conn.createStatement();
......@@ -136,14 +136,14 @@ public class TestTransaction extends TestBase {
conn.close();
}
private void checkTableCount(Statement stat, String tableName, int count) throws Exception {
private void checkTableCount(Statement stat, String tableName, int count) throws SQLException {
ResultSet rs;
rs = stat.executeQuery("SELECT COUNT(*) FROM " + tableName);
rs.next();
assertEquals(count, rs.getInt(1));
}
private void testIsolation() throws Exception {
private void testIsolation() throws SQLException {
Connection conn = getConnection("transaction");
trace("default TransactionIsolation=" + conn.getTransactionIsolation());
conn.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
......@@ -174,7 +174,7 @@ public class TestTransaction extends TestBase {
conn.close();
}
private void testNestedResultSets(Connection conn) throws Exception {
private void testNestedResultSets(Connection conn) throws SQLException {
Statement stat = conn.createStatement();
test(stat, "CREATE TABLE NEST1(ID INT PRIMARY KEY,VALUE VARCHAR(255))");
test(stat, "CREATE TABLE NEST2(ID INT PRIMARY KEY,VALUE VARCHAR(255))");
......@@ -236,7 +236,7 @@ public class TestTransaction extends TestBase {
test(stat, "DROP TABLE NEST2");
}
private void testValue(Statement stat, String sql, String data) throws Exception {
private void testValue(Statement stat, String sql, String data) throws SQLException {
ResultSet rs = stat.executeQuery(sql);
rs.next();
String s = rs.getString(1);
......@@ -245,7 +245,7 @@ public class TestTransaction extends TestBase {
}
}
private void test(Statement stat, String sql) throws Exception {
private void test(Statement stat, String sql) throws SQLException {
trace(sql);
stat.execute(sql);
}
......
......@@ -25,7 +25,7 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
private String triggerName;
public void test() throws Exception {
public void test() throws SQLException {
deleteDb("trigger");
testTriggerAlterTable();
testTriggers();
......@@ -47,7 +47,7 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
}
}
private void testTriggerAlterTable() throws Exception {
private void testTriggerAlterTable() throws SQLException {
Connection conn = getConnection("trigger");
Statement stat = conn.createStatement();
stat.execute("DROP TABLE IF EXISTS TEST");
......@@ -65,7 +65,7 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
conn.close();
}
private void testConstraints() throws Exception {
private void testConstraints() throws SQLException {
Connection conn = getConnection("trigger");
Statement stat = conn.createStatement();
stat.execute("DROP TABLE IF EXISTS TEST");
......@@ -78,7 +78,7 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
conn.close();
}
private void testTriggers() throws Exception {
private void testTriggers() throws SQLException {
mustNotCallTrigger = false;
Connection conn = getConnection("trigger");
Statement stat = conn.createStatement();
......@@ -142,7 +142,7 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
conn.close();
}
private void checkRows(ResultSet rs, String[] expected) throws Exception {
private void checkRows(ResultSet rs, String[] expected) throws SQLException {
HashSet set = new HashSet(Arrays.asList(expected));
while (rs.next()) {
set.remove(rs.getString(1));
......
......@@ -8,6 +8,7 @@ package org.h2.test.db;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
......@@ -17,7 +18,7 @@ import org.h2.test.TestBase;
* Tests for the two-phase-commit feature.
*/
public class TestTwoPhaseCommit extends TestBase {
public void test() throws Exception {
public void test() throws SQLException {
if (config.memory || config.networked || config.logMode == 0) {
return;
}
......@@ -33,7 +34,7 @@ public class TestTwoPhaseCommit extends TestBase {
test(false);
}
private void test(boolean rolledBack) throws Exception {
private void test(boolean rolledBack) throws SQLException {
Connection conn = getConnection("twoPhaseCommit");
Statement stat = conn.createStatement();
stat.execute("SET WRITE_DELAY 0");
......@@ -50,7 +51,7 @@ public class TestTwoPhaseCommit extends TestBase {
conn.close();
}
private void openWith(boolean rollback) throws Exception {
private void openWith(boolean rollback) throws SQLException {
Connection conn = getConnection("twoPhaseCommit");
Statement stat = conn.createStatement();
ArrayList list = new ArrayList();
......@@ -69,7 +70,7 @@ public class TestTwoPhaseCommit extends TestBase {
conn.close();
}
private void prepare() throws Exception {
private void prepare() throws SQLException {
deleteDb("twoPhaseCommit");
Connection conn = getConnection("twoPhaseCommit");
Statement stat = conn.createStatement();
......
......@@ -8,6 +8,7 @@ package org.h2.test.db;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import org.h2.test.TestBase;
......@@ -17,12 +18,12 @@ import org.h2.test.TestBase;
*/
public class TestView extends TestBase {
public void test() throws Exception {
public void test() throws SQLException {
testUnionReconnect();
testManyViews();
}
private void testUnionReconnect() throws Exception {
private void testUnionReconnect() throws SQLException {
if (config.memory) {
return;
}
......@@ -47,7 +48,7 @@ public class TestView extends TestBase {
deleteDb("view");
}
private void testManyViews() throws Exception {
private void testManyViews() throws SQLException {
deleteDb("view");
Connection conn = getConnection("view");
Statement s = conn.createStatement();
......
......@@ -39,11 +39,11 @@ public class SamplesTest extends TestBase {
*
* @param args the command line parameters
*/
public static void main(String[] args) throws Exception {
public static void main(String[] args) {
new SamplesTest().test();
}
public void test() throws Exception {
public void test() {
//## Java 1.5 begin ##
db = Db.open("jdbc:h2:mem:", "sa", "sa");
db.insertAll(Product.getList());
......@@ -80,7 +80,7 @@ public class SamplesTest extends TestBase {
}
//## Java 1.5 begin ##
private void testWhereSimple2() throws Exception {
private void testWhereSimple2() {
// var soldOutProducts =
// from p in products
......@@ -96,7 +96,7 @@ public class SamplesTest extends TestBase {
assertEquals("[Chef Anton's Gumbo Mix: 0]", soldOutProducts.toString());
}
private void testWhereSimple3() throws Exception {
private void testWhereSimple3() {
// var expensiveInStockProducts =
// from p in products
......@@ -116,7 +116,7 @@ public class SamplesTest extends TestBase {
}
private void testWhereSimple4() throws Exception {
private void testWhereSimple4() {
// var waCustomers =
// from c in customers
......@@ -132,7 +132,7 @@ public class SamplesTest extends TestBase {
assertEquals("[ALFKI, ANATR]", waCustomers.toString());
}
private void testSelectSimple2() throws Exception {
private void testSelectSimple2() {
// var productNames =
// from p in products
......@@ -160,7 +160,7 @@ public class SamplesTest extends TestBase {
}
//## Java 1.5 begin ##
private void testAnonymousTypes3() throws Exception {
private void testAnonymousTypes3() {
// var productInfos =
// from p in products
......@@ -204,7 +204,7 @@ public class SamplesTest extends TestBase {
}
//## Java 1.5 begin ##
private void testSelectManyCompoundFrom2() throws Exception {
private void testSelectManyCompoundFrom2() {
// var orders =
// from c in customers,
......@@ -232,13 +232,13 @@ public class SamplesTest extends TestBase {
assertEquals("[ANATR:10308:88.80]", orders.toString());
}
private void testIsNull() throws Exception {
private void testIsNull() {
Product p = new Product();
String sql = db.from(p).whereTrue(isNull(p.productName)).getSQL();
assertEquals("SELECT * FROM Product WHERE (productName IS NULL)", sql);
}
private void testDelete() throws Exception {
private void testDelete() {
Product p = new Product();
int deleted = db.from(p).where(p.productName).like("A%").delete();
assertEquals(1, deleted);
......@@ -247,7 +247,7 @@ public class SamplesTest extends TestBase {
db.insertAll(Product.getList());
}
private void testOrAndNot() throws Exception {
private void testOrAndNot() {
Product p = new Product();
String sql = db.from(p).whereTrue(not(isNull(p.productName))).getSQL();
assertEquals("SELECT * FROM Product WHERE (NOT productName IS NULL)", sql);
......@@ -257,7 +257,7 @@ public class SamplesTest extends TestBase {
assertEquals("SELECT * FROM Product WHERE ((productId = ?))", sql);
}
private void testLength() throws Exception {
private void testLength() {
Product p = new Product();
List<Integer> lengths = db.from(p).
where(length(p.productName)).smaller(10).
......@@ -266,7 +266,7 @@ public class SamplesTest extends TestBase {
assertEquals("[4, 5]", lengths.toString());
}
private void testSum() throws Exception {
private void testSum() {
Product p = new Product();
Integer sum = db.from(p).selectFirst(sum(p.unitsInStock));
assertEquals(323, sum.intValue());
......@@ -274,7 +274,7 @@ public class SamplesTest extends TestBase {
assertEquals(313.35, sumPrice.doubleValue());
}
private void testMinMax() throws Exception {
private void testMinMax() {
Product p = new Product();
Integer min = db.from(p).selectFirst(min(p.unitsInStock));
assertEquals(0, min.intValue());
......@@ -284,7 +284,7 @@ public class SamplesTest extends TestBase {
assertEquals(97.0, max.doubleValue());
}
private void testLike() throws Exception {
private void testLike() {
Product p = new Product();
List<Product> aList = db.from(p).
where(p.productName).like("Cha%").
......@@ -292,12 +292,12 @@ public class SamplesTest extends TestBase {
assertEquals("[Chai: 39, Chang: 17]", aList.toString());
}
private void testCount() throws Exception {
private void testCount() {
long count = db.from(new Product()).selectCount();
assertEquals(10, count);
}
private void testComplexObject() throws Exception {
private void testComplexObject() {
ComplexObject co = new ComplexObject();
long count = db.from(co).
where(co.id).is(1).
......@@ -325,7 +325,7 @@ public class SamplesTest extends TestBase {
}
//## Java 1.5 begin ##
private void testGroup() throws Exception {
private void testGroup() {
// var orderGroups =
// from p in products
......
......@@ -14,6 +14,7 @@ import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import org.h2.test.TestBase;
......@@ -42,13 +43,13 @@ public class TestBatchUpdates extends TestBase {
private Statement stat;
private PreparedStatement prep;
public void test() throws Exception {
public void test() throws SQLException {
testExecuteCall();
testException();
testCoffee();
}
private void testExecuteCall() throws Exception {
private void testExecuteCall() throws SQLException {
deleteDb("batchUpdates");
Connection conn = getConnection("batchUpdates");
Statement stat = conn.createStatement();
......@@ -80,7 +81,7 @@ public class TestBatchUpdates extends TestBase {
return (int) f;
}
private void testException() throws Exception {
private void testException() throws SQLException {
deleteDb("batchUpdates");
Connection conn = getConnection("batchUpdates");
Statement stat = conn.createStatement();
......@@ -106,7 +107,7 @@ public class TestBatchUpdates extends TestBase {
conn.close();
}
private void testCoffee() throws Exception {
private void testCoffee() throws SQLException {
deleteDb("batchUpdates");
this.conn = getConnection("batchUpdates");
stat = conn.createStatement();
......@@ -151,7 +152,7 @@ public class TestBatchUpdates extends TestBase {
conn.close();
}
private void testAddBatch01() throws Exception {
private void testAddBatch01() throws SQLException {
trace("testAddBatch01");
int i = 0;
int[] retValue = { 0, 0, 0 };
......@@ -200,7 +201,7 @@ public class TestBatchUpdates extends TestBase {
}
}
private void testAddBatch02() throws Exception {
private void testAddBatch02() throws SQLException {
trace("testAddBatch02");
int i = 0;
int[] retValue = { 0, 0, 0 };
......@@ -237,7 +238,7 @@ public class TestBatchUpdates extends TestBase {
}
}
private void testClearBatch01() throws Exception {
private void testClearBatch01() throws SQLException {
trace("testClearBatch01");
String sPrepStmt = COFFEE_UPDATE;
trace("Prepared Statement String:" + sPrepStmt);
......@@ -258,7 +259,7 @@ public class TestBatchUpdates extends TestBase {
}
}
private void testClearBatch02() throws Exception {
private void testClearBatch02() throws SQLException {
trace("testClearBatch02");
int updCountLength = 0;
String sUpdCoffee = COFFEE_UPDATE1;
......@@ -278,7 +279,7 @@ public class TestBatchUpdates extends TestBase {
}
}
private void testExecuteBatch01() throws Exception {
private void testExecuteBatch01() throws SQLException {
trace("testExecuteBatch01");
int i = 0;
int[] retValue = { 0, 0, 0 };
......@@ -327,7 +328,7 @@ public class TestBatchUpdates extends TestBase {
}
}
private void testExecuteBatch02() throws Exception {
private void testExecuteBatch02() throws SQLException {
trace("testExecuteBatch02");
String sPrepStmt = COFFEE_UPDATE;
trace("Prepared Statement String:" + sPrepStmt);
......@@ -345,7 +346,7 @@ public class TestBatchUpdates extends TestBase {
}
}
private void testExecuteBatch03() throws Exception {
private void testExecuteBatch03() throws SQLException {
trace("testExecuteBatch03");
boolean batchExceptionFlag = false;
String sPrepStmt = COFFEE_SELECT;
......@@ -366,7 +367,7 @@ public class TestBatchUpdates extends TestBase {
}
}
private void testExecuteBatch04() throws Exception {
private void testExecuteBatch04() throws SQLException {
trace("testExecuteBatch04");
int i = 0;
int[] retValue = { 0, 0, 0 };
......@@ -402,7 +403,7 @@ public class TestBatchUpdates extends TestBase {
}
}
private void testExecuteBatch05() throws Exception {
private void testExecuteBatch05() throws SQLException {
trace("testExecuteBatch05");
int updCountLength = 0;
int[] updateCount = stat.executeBatch();
......@@ -415,7 +416,7 @@ public class TestBatchUpdates extends TestBase {
}
}
private void testExecuteBatch06() throws Exception {
private void testExecuteBatch06() throws SQLException {
trace("testExecuteBatch06");
boolean batchExceptionFlag = false;
// Insert a row which is already Present
......@@ -440,7 +441,7 @@ public class TestBatchUpdates extends TestBase {
}
}
private void testExecuteBatch07() throws Exception {
private void testExecuteBatch07() throws SQLException {
trace("testExecuteBatch07");
boolean batchExceptionFlag = false;
String selectCoffee = COFFEE_SELECT1;
......@@ -460,7 +461,7 @@ public class TestBatchUpdates extends TestBase {
}
}
private void testContinueBatch01() throws Exception {
private void testContinueBatch01() throws SQLException {
trace("testContinueBatch01");
int[] batchUpdates = { 0, 0, 0 };
int buCountLen = 0;
......
......@@ -9,6 +9,7 @@ package org.h2.test.jdbc;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import org.h2.test.TestBase;
......@@ -18,14 +19,14 @@ import org.h2.test.TestBase;
*/
public class TestCallableStatement extends TestBase {
public void test() throws Exception {
public void test() throws SQLException {
deleteDb("callableStatement");
Connection conn = getConnection("preparedStatement");
testPrepare(conn);
conn.close();
}
private void testPrepare(Connection conn) throws Exception {
private void testPrepare(Connection conn) throws SQLException {
Statement stat = conn.createStatement();
CallableStatement call;
ResultSet rs;
......
......@@ -68,7 +68,7 @@ public class TestCancel extends TestBase {
testCancelStatement();
}
private void testReset() throws Exception {
private void testReset() throws SQLException {
deleteDb("cancel");
Connection conn = getConnection("cancel");
Statement stat = conn.createStatement();
......@@ -84,7 +84,7 @@ public class TestCancel extends TestBase {
conn.close();
}
private void testQueryTimeoutInTransaction() throws Exception {
private void testQueryTimeoutInTransaction() throws SQLException {
deleteDb("cancel");
Connection conn = getConnection("cancel");
Statement stat = conn.createStatement();
......@@ -99,7 +99,7 @@ public class TestCancel extends TestBase {
conn.close();
}
private void testJdbcQueryTimeout() throws Exception {
private void testJdbcQueryTimeout() throws SQLException {
deleteDb("cancel");
Connection conn = getConnection("cancel");
Statement stat = conn.createStatement();
......@@ -123,7 +123,7 @@ public class TestCancel extends TestBase {
conn.close();
}
private void testQueryTimeout() throws Exception {
private void testQueryTimeout() throws SQLException {
deleteDb("cancel");
Connection conn = getConnection("cancel");
Statement stat = conn.createStatement();
......@@ -137,7 +137,7 @@ public class TestCancel extends TestBase {
conn.close();
}
private void testMaxQueryTimeout() throws Exception {
private void testMaxQueryTimeout() throws SQLException {
deleteDb("cancel");
int oldMax = SysProperties.getMaxQueryTimeout();
try {
......
......@@ -22,13 +22,13 @@ public class TestDatabaseEventListener extends TestBase implements DatabaseEvent
private boolean calledOpened, calledClosingDatabase, calledScan;
public void test() throws Exception {
public void test() throws SQLException {
testCalled();
testCloseLog0(false);
testCloseLog0(true);
}
private void testCloseLog0(boolean shutdown) throws Exception {
private void testCloseLog0(boolean shutdown) throws SQLException {
if (config.memory) {
return;
}
......@@ -57,7 +57,7 @@ public class TestDatabaseEventListener extends TestBase implements DatabaseEvent
}
}
private void testCalled() throws Exception {
private void testCalled() throws SQLException {
Properties p = new Properties();
p.setProperty("user", "sa");
p.setProperty("password", "sa");
......
......@@ -10,6 +10,7 @@ import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import org.h2.constant.SysProperties;
......@@ -20,13 +21,13 @@ import org.h2.test.TestBase;
*/
public class TestManyJdbcObjects extends TestBase {
public void test() throws Exception {
public void test() throws SQLException {
testNestedResultSets();
testManyConnections();
testOneConnectionPrepare();
}
private void testNestedResultSets() throws Exception {
private void testNestedResultSets() throws SQLException {
if (!config.networked) {
return;
}
......@@ -41,7 +42,7 @@ public class TestManyJdbcObjects extends TestBase {
conn.close();
}
private void testManyConnections() throws Exception {
private void testManyConnections() throws SQLException {
if (!config.networked || config.memory) {
return;
}
......@@ -70,7 +71,7 @@ public class TestManyJdbcObjects extends TestBase {
SysProperties.runFinalize = true;
}
private void testOneConnectionPrepare() throws Exception {
private void testOneConnectionPrepare() throws SQLException {
deleteDb("manyObjects");
SysProperties.runFinalize = false;
Connection conn = getConnection("manyObjects");
......
......@@ -11,6 +11,7 @@ import java.sql.DatabaseMetaData;
import java.sql.Driver;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Types;
......@@ -28,7 +29,7 @@ public class TestMetaData extends TestBase {
private Statement stat;
private String catalog = "METADATA";
public void test() throws Exception {
public void test() throws SQLException {
deleteDb("metaData");
conn = getConnection("metaData");
......@@ -197,7 +198,7 @@ public class TestMetaData extends TestBase {
}
private void testColumnLobMeta() throws Exception {
private void testColumnLobMeta() throws SQLException {
Statement stat = conn.createStatement();
stat.executeUpdate("CREATE TABLE t (blob BLOB, clob CLOB)");
stat.execute("INSERT INTO t VALUES('', '')");
......@@ -211,7 +212,7 @@ public class TestMetaData extends TestBase {
stat.executeUpdate("DROP TABLE t");
}
private void testColumnMetaData() throws Exception {
private void testColumnMetaData() throws SQLException {
String statement = "select substring('Hello',0,1)";
ResultSet rs = conn.prepareStatement(statement).executeQuery();
rs.next();
......@@ -219,7 +220,7 @@ public class TestMetaData extends TestBase {
assertEquals(Types.VARCHAR, type);
}
private void testColumnPrecision() throws Exception {
private void testColumnPrecision() throws SQLException {
Statement stat = conn.createStatement();
stat.execute("CREATE TABLE ONE(X NUMBER(12,2), Y FLOAT)");
stat.execute("CREATE TABLE TWO AS SELECT * FROM ONE");
......@@ -240,7 +241,7 @@ public class TestMetaData extends TestBase {
stat.execute("DROP TABLE ONE, TWO");
}
private void testColumnDefault() throws Exception {
private void testColumnDefault() throws SQLException {
DatabaseMetaData meta = conn.getMetaData();
ResultSet rs;
Statement stat = conn.createStatement();
......@@ -256,7 +257,7 @@ public class TestMetaData extends TestBase {
stat.execute("DROP TABLE TEST");
}
private void testProcedureColumns() throws Exception {
private void testProcedureColumns() throws SQLException {
DatabaseMetaData meta = conn.getMetaData();
ResultSet rs;
Statement stat = conn.createStatement();
......@@ -286,7 +287,7 @@ public class TestMetaData extends TestBase {
stat.execute("DROP ALIAS PROP");
}
private void testCrossReferences() throws Exception {
private void testCrossReferences() throws SQLException {
DatabaseMetaData meta = conn.getMetaData();
ResultSet rs;
Statement stat = conn.createStatement();
......@@ -303,7 +304,7 @@ public class TestMetaData extends TestBase {
stat.execute("DROP TABLE CHILD");
}
private void checkCrossRef(ResultSet rs) throws Exception {
private void checkCrossRef(ResultSet rs) throws SQLException {
assertResultSetMeta(rs, 14, new String[] { "PKTABLE_CAT", "PKTABLE_SCHEM", "PKTABLE_NAME", "PKCOLUMN_NAME",
"FKTABLE_CAT", "FKTABLE_SCHEM", "FKTABLE_NAME", "FKCOLUMN_NAME", "KEY_SEQ", "UPDATE_RULE",
"DELETE_RULE", "FK_NAME", "PK_NAME", "DEFERRABILITY" }, new int[] { Types.VARCHAR, Types.VARCHAR,
......@@ -319,7 +320,7 @@ public class TestMetaData extends TestBase {
null, "" + DatabaseMetaData.importedKeyNotDeferrable } });
}
private void testTempTable() throws Exception {
private void testTempTable() throws SQLException {
Connection conn = getConnection("metaData");
Statement stat = conn.createStatement();
stat.execute("DROP TABLE IF EXISTS TEST_TEMP");
......@@ -339,8 +340,8 @@ public class TestMetaData extends TestBase {
conn.close();
}
private void testStatic() throws Exception {
Driver dr = (Driver) Class.forName("org.h2.Driver").newInstance();
private void testStatic() throws SQLException {
Driver dr = org.h2.Driver.load();
assertEquals(dr.getMajorVersion(), meta.getDriverMajorVersion());
assertEquals(dr.getMinorVersion(), meta.getDriverMinorVersion());
......@@ -536,7 +537,7 @@ public class TestMetaData extends TestBase {
assertTrue(meta.usesLocalFiles());
}
private void test(Connection conn) throws Exception {
private void test(Connection conn) throws SQLException {
DatabaseMetaData meta = conn.getMetaData();
Statement stat = conn.createStatement();
ResultSet rs;
......
......@@ -55,7 +55,7 @@ public class TestNativeSQL extends TestBase {
private Connection conn;
public void test() throws Exception {
public void test() throws SQLException {
deleteDb("nativeSql");
conn = getConnection("nativeSql");
testPairs();
......@@ -66,7 +66,7 @@ public class TestNativeSQL extends TestBase {
assertTrue(conn.isClosed());
}
private void testQuotes() throws Exception {
private void testQuotes() throws SQLException {
Statement stat = conn.createStatement();
Random random = new Random(1);
String s = "'\"$/-* \n";
......@@ -105,7 +105,7 @@ public class TestNativeSQL extends TestBase {
}
}
private void testRandom() throws Exception {
private void testRandom() throws SQLException {
Random random = new Random(1);
for (int i = 0; i < 100; i++) {
StringBuffer buff = new StringBuffer("{oj }");
......@@ -197,13 +197,13 @@ public class TestNativeSQL extends TestBase {
}
}
private void testPairs() throws Exception {
private void testPairs() throws SQLException {
for (int i = 0; i < PAIRS.length; i += 2) {
test(conn, PAIRS[i], PAIRS[i + 1]);
}
}
private void testCases() throws Exception {
private void testCases() throws SQLException {
conn.nativeSQL("TEST");
conn.nativeSQL("TEST--testing");
conn.nativeSQL("TEST--testing{oj }");
......@@ -231,7 +231,7 @@ public class TestNativeSQL extends TestBase {
assertFalse(conn.isClosed());
}
private void test(Connection conn, String original, String expected) throws Exception {
private void test(Connection conn, String original, String expected) throws SQLException {
trace("original: <" + original + ">");
trace("expected: <" + expected + ">");
try {
......
......@@ -36,7 +36,7 @@ public class TestResultSet extends TestBase {
private Connection conn;
private Statement stat;
public void test() throws Exception {
public void test() throws SQLException {
deleteDb("resultSet");
conn = getConnection("resultSet");
......@@ -70,7 +70,7 @@ public class TestResultSet extends TestBase {
}
private void testAbsolute() throws Exception {
private void testAbsolute() throws SQLException {
// stat.execute("SET MAX_MEMORY_ROWS 90");
stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY)");
// there was a problem when more than MAX_MEMORY_ROWS where in the result set
......@@ -84,7 +84,7 @@ public class TestResultSet extends TestBase {
stat.execute("DROP TABLE TEST");
}
private void testFetchSize() throws Exception {
private void testFetchSize() throws SQLException {
if (!config.networked || config.memory) {
return;
}
......@@ -97,7 +97,7 @@ public class TestResultSet extends TestBase {
assertEquals(a + 1, b);
}
private void testOwnUpdates() throws Exception {
private void testOwnUpdates() throws SQLException {
DatabaseMetaData meta = conn.getMetaData();
for (int i = 0; i < 3; i++) {
int type = i == 0 ? ResultSet.TYPE_FORWARD_ONLY : i == 1 ? ResultSet.TYPE_SCROLL_INSENSITIVE : ResultSet.TYPE_SCROLL_SENSITIVE;
......@@ -120,12 +120,12 @@ public class TestResultSet extends TestBase {
stat.execute("DROP TABLE TEST");
}
private void checkPrecision(int expected, String sql) throws Exception {
private void checkPrecision(int expected, String sql) throws SQLException {
ResultSetMetaData meta = stat.executeQuery(sql).getMetaData();
assertEquals(expected, meta.getPrecision(1));
}
private void testSubstringPrecision() throws Exception {
private void testSubstringPrecision() throws SQLException {
trace("testSubstringPrecision");
stat.execute("CREATE TABLE TEST(ID INT, NAME VARCHAR(10))");
stat.execute("INSERT INTO TEST VALUES(1, 'Hello'), (2, 'WorldPeace')");
......@@ -139,7 +139,7 @@ public class TestResultSet extends TestBase {
stat.execute("DROP TABLE TEST");
}
private void testFindColumn() throws Exception {
private void testFindColumn() throws SQLException {
trace("testFindColumn");
ResultSet rs;
stat.execute("CREATE TABLE TEST(ID INT, NAME VARCHAR)");
......@@ -177,7 +177,7 @@ public class TestResultSet extends TestBase {
}
private void testColumnLength() throws Exception {
private void testColumnLength() throws SQLException {
trace("testColumnDisplayLength");
ResultSet rs;
ResultSetMetaData meta;
......@@ -214,7 +214,7 @@ public class TestResultSet extends TestBase {
}
private void testLimitMaxRows() throws Exception {
private void testLimitMaxRows() throws SQLException {
trace("Test LimitMaxRows");
ResultSet rs;
stat.execute("CREATE TABLE one (C CHARACTER(10))");
......@@ -234,7 +234,7 @@ public class TestResultSet extends TestBase {
stat.execute("DROP TABLE one");
}
private void testAutoIncrement() throws Exception {
private void testAutoIncrement() throws SQLException {
trace("Test AutoIncrement");
stat.execute("DROP TABLE IF EXISTS TEST");
ResultSet rs;
......@@ -264,7 +264,7 @@ public class TestResultSet extends TestBase {
}
private void testInt() throws Exception {
private void testInt() throws SQLException {
trace("Test INT");
ResultSet rs;
Object o;
......@@ -420,7 +420,7 @@ public class TestResultSet extends TestBase {
stat.setMaxRows(0);
}
private void testVarchar() throws Exception {
private void testVarchar() throws SQLException {
trace("Test VARCHAR");
ResultSet rs;
Object o;
......@@ -504,7 +504,7 @@ public class TestResultSet extends TestBase {
stat.execute("DROP TABLE TEST");
}
private void testDecimal() throws Exception {
private void testDecimal() throws SQLException {
trace("Test DECIMAL");
ResultSet rs;
Object o;
......@@ -555,7 +555,7 @@ public class TestResultSet extends TestBase {
stat.execute("DROP TABLE TEST");
}
private void testDoubleFloat() throws Exception {
private void testDoubleFloat() throws SQLException {
trace("Test DOUBLE - FLOAT");
ResultSet rs;
Object o;
......@@ -621,7 +621,7 @@ public class TestResultSet extends TestBase {
stat.execute("DROP TABLE TEST");
}
private void testDatetime() throws Exception {
private void testDatetime() throws SQLException {
trace("Test DATETIME");
ResultSet rs;
Object o;
......@@ -702,7 +702,7 @@ public class TestResultSet extends TestBase {
stat.execute("DROP TABLE TEST");
}
private void testDatetimeWithCalendar() throws Exception {
private void testDatetimeWithCalendar() throws SQLException {
trace("Test DATETIME with Calendar");
ResultSet rs;
......@@ -795,7 +795,7 @@ public class TestResultSet extends TestBase {
stat.execute("DROP TABLE TEST");
}
private void testBlob() throws Exception {
private void testBlob() throws SQLException {
trace("Test BLOB");
ResultSet rs;
......@@ -833,7 +833,7 @@ public class TestResultSet extends TestBase {
stat.execute("DROP TABLE TEST");
}
private void testClob() throws Exception {
private void testClob() throws SQLException {
trace("Test CLOB");
ResultSet rs;
String string;
......@@ -900,7 +900,7 @@ public class TestResultSet extends TestBase {
stat.execute("DROP TABLE TEST");
}
private void testArray() throws Exception {
private void testArray() throws SQLException {
trace("Test ARRAY");
ResultSet rs;
stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY, VALUE ARRAY)");
......@@ -938,7 +938,7 @@ public class TestResultSet extends TestBase {
stat.execute("DROP TABLE TEST");
}
private byte[] readAllBytes(InputStream in) throws Exception {
private byte[] readAllBytes(InputStream in) throws SQLException {
if (in == null) {
return null;
}
......@@ -958,7 +958,7 @@ public class TestResultSet extends TestBase {
}
}
private void checkBytes(byte[] test, byte[] good) throws Exception {
private void checkBytes(byte[] test, byte[] good) throws SQLException {
if (test == null || good == null) {
assertTrue(test == good);
} else {
......@@ -966,7 +966,7 @@ public class TestResultSet extends TestBase {
}
}
private void checkColumnBigDecimal(ResultSet rs, int column, int i, String bd) throws Exception {
private void checkColumnBigDecimal(ResultSet rs, int column, int i, String bd) throws SQLException {
BigDecimal bd1 = rs.getBigDecimal(column);
int i1 = rs.getInt(column);
if (bd == null) {
......
......@@ -23,7 +23,7 @@ public class TestStatement extends TestBase {
private Connection conn;
public void test() throws Exception {
public void test() throws SQLException {
deleteDb("statement");
conn = getConnection("statement");
if (config.jdk14) {
......@@ -37,7 +37,7 @@ public class TestStatement extends TestBase {
conn.close();
}
private void testConnectionRollback() throws Exception {
private void testConnectionRollback() throws SQLException {
Statement stat = conn.createStatement();
conn.setAutoCommit(false);
stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR(255))");
......@@ -49,7 +49,7 @@ public class TestStatement extends TestBase {
conn.setAutoCommit(true);
}
private void testSavepoint() throws Exception {
private void testSavepoint() throws SQLException {
Statement stat = conn.createStatement();
stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR(255))");
conn.setAutoCommit(false);
......@@ -103,7 +103,7 @@ public class TestStatement extends TestBase {
conn.setAutoCommit(true);
}
private void testStatement() throws Exception {
private void testStatement() throws SQLException {
Statement stat = conn.createStatement();
......@@ -278,7 +278,7 @@ public class TestStatement extends TestBase {
stat.close();
}
private void testIdentity() throws Exception {
private void testIdentity() throws SQLException {
Statement stat = conn.createStatement();
stat.execute("CREATE SEQUENCE SEQ");
stat.execute("CREATE TABLE TEST(ID INT)");
......
......@@ -18,7 +18,7 @@ public class TestTransactionIsolation extends TestBase {
private Connection conn1, conn2;
public void test() throws Exception {
public void test() throws SQLException {
if (config.mvcc) {
// no tests yet
} else {
......@@ -26,7 +26,7 @@ public class TestTransactionIsolation extends TestBase {
}
}
private void testTableLevelLocking() throws Exception {
private void testTableLevelLocking() throws SQLException {
deleteDb("transactionIsolation");
conn1 = getConnection("transactionIsolation");
assertEquals(conn1.getTransactionIsolation(), Connection.TRANSACTION_READ_COMMITTED);
......
......@@ -27,7 +27,7 @@ import org.h2.test.TestBase;
*/
public class TestUpdatableResultSet extends TestBase {
public void test() throws Exception {
public void test() throws SQLException {
testUpdateLob();
testScroll();
testUpdateDeleteInsert();
......@@ -35,7 +35,7 @@ public class TestUpdatableResultSet extends TestBase {
testUpdateResetRead();
}
private void testUpdateLob() throws Exception {
private void testUpdateLob() throws SQLException {
deleteDb("updatableResultSet");
Connection conn = getConnection("updatableResultSet");
Statement stat = conn.createStatement();
......@@ -62,7 +62,7 @@ public class TestUpdatableResultSet extends TestBase {
conn.close();
}
private void testUpdateResetRead() throws Exception {
private void testUpdateResetRead() throws SQLException {
deleteDb("updatableResultSet");
Connection conn = getConnection("updatableResultSet");
Statement stat = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
......@@ -86,7 +86,7 @@ public class TestUpdatableResultSet extends TestBase {
conn.close();
}
private void testScroll() throws Exception {
private void testScroll() throws SQLException {
deleteDb("updatableResultSet");
Connection conn = getConnection("updatableResultSet");
Statement stat = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
......@@ -194,7 +194,7 @@ public class TestUpdatableResultSet extends TestBase {
conn.close();
}
private void testUpdateDataType() throws Exception {
private void testUpdateDataType() throws SQLException {
deleteDb("updatableResultSet");
Connection conn = getConnection("updatableResultSet");
Statement stat = conn.createStatement();
......@@ -328,7 +328,7 @@ public class TestUpdatableResultSet extends TestBase {
conn.close();
}
private void testUpdateDeleteInsert() throws Exception {
private void testUpdateDeleteInsert() throws SQLException {
deleteDb("updatableResultSet");
Connection c1 = getConnection("updatableResultSet");
Connection c2 = getConnection("updatableResultSet");
......@@ -387,7 +387,7 @@ public class TestUpdatableResultSet extends TestBase {
conn.close();
}
private void testScrollable(Connection conn, int rows) throws Exception {
private void testScrollable(Connection conn, int rows) throws SQLException {
Statement stat = conn.createStatement();
stat.execute("CREATE TABLE IF NOT EXISTS TEST(ID INT PRIMARY KEY, NAME VARCHAR(255))");
stat.execute("DELETE FROM TEST");
......@@ -403,7 +403,7 @@ public class TestUpdatableResultSet extends TestBase {
testScrollResultSet(scroll, ResultSet.TYPE_SCROLL_INSENSITIVE, rows);
}
private void testScrollResultSet(Statement stat, int type, int rows) throws Exception {
private void testScrollResultSet(Statement stat, int type, int rows) throws SQLException {
boolean error = false;
if (type == ResultSet.TYPE_FORWARD_ONLY) {
error = true;
......@@ -456,7 +456,7 @@ public class TestUpdatableResultSet extends TestBase {
}
}
private void checkState(ResultSet rs, boolean beforeFirst, boolean first, boolean last, boolean afterLast) throws Exception {
private void checkState(ResultSet rs, boolean beforeFirst, boolean first, boolean last, boolean afterLast) throws SQLException {
assertEquals(rs.isBeforeFirst(), beforeFirst);
assertEquals(rs.isFirst(), first);
assertEquals(rs.isLast(), last);
......
......@@ -20,7 +20,7 @@ import org.h2.test.TestBase;
*/
public class TestZloty extends TestBase {
public void test() throws Exception {
public void test() throws SQLException {
testZloty();
testModifyBytes();
}
......@@ -42,7 +42,7 @@ public class TestZloty extends TestBase {
}
private void testModifyBytes() throws Exception {
private void testModifyBytes() throws SQLException {
deleteDb("zloty");
Connection conn = getConnection("zloty");
conn.createStatement().execute("CREATE TABLE TEST(ID INT, DATA BINARY)");
......@@ -73,7 +73,7 @@ public class TestZloty extends TestBase {
*
* @author Maciej Wegorkiewicz
*/
private void testZloty() throws Exception {
private void testZloty() throws SQLException {
deleteDb("zloty");
Connection conn = getConnection("zloty");
conn.createStatement().execute("CREATE TABLE TEST(ID INT, AMOUNT DECIMAL)");
......
......@@ -7,6 +7,7 @@
package org.h2.test.jdbcx;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import org.h2.jdbcx.JdbcConnectionPool;
......@@ -64,7 +65,7 @@ public class TestConnectionPool extends TestBase {
man.dispose();
}
private JdbcConnectionPool getConnectionPool(int poolSize) throws Exception {
private JdbcConnectionPool getConnectionPool(int poolSize) throws SQLException {
JdbcDataSource ds = new JdbcDataSource();
ds.setURL(getURL("connectionPool", true));
ds.setUser(getUser());
......@@ -74,7 +75,7 @@ public class TestConnectionPool extends TestBase {
return pool;
}
private void testConnect() throws Exception {
private void testConnect() throws SQLException {
JdbcConnectionPool man = getConnectionPool(3);
for (int i = 0; i < 100; i++) {
Connection conn = man.getConnection();
......
......@@ -7,6 +7,7 @@
package org.h2.test.jdbcx;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import javax.sql.ConnectionEvent;
......@@ -23,7 +24,7 @@ import org.h2.test.TestBase;
*/
public class TestDataSource extends TestBase {
// public static void main(String[] args) throws Exception {
// public static void main(String[] args) throws SQLException {
//
// // first, need to start on the command line:
// // rmiregistry 1099
......@@ -76,7 +77,7 @@ public class TestDataSource extends TestBase {
xaConn.close();
}
private void testDataSource() throws Exception {
private void testDataSource() throws SQLException {
deleteDb(baseDir, "dataSource");
JdbcDataSource ds = new JdbcDataSource();
ds.setURL("jdbc:h2:" + baseDir + "/dataSource");
......
......@@ -7,6 +7,7 @@
package org.h2.test.jdbcx;
import java.sql.Connection;
import java.sql.SQLException;
import javax.sql.XAConnection;
......@@ -18,11 +19,11 @@ import org.h2.test.TestBase;
*/
public class TestXASimple extends TestBase {
public void test() throws Exception {
public void test() throws SQLException {
deleteDb("xaSimple1");
deleteDb("xaSimple2");
Class.forName("org.h2.Driver");
org.h2.Driver.load();
// InitialContext context = new InitialContext();
// context.rebind(USER_TRANSACTION_JNDI_NAME, j.getUserTransaction());
......
......@@ -23,12 +23,12 @@ public class TestMvcc1 extends TestBase {
private Connection c1, c2;
private Statement s1, s2;
public void test() throws Exception {
public void test() throws SQLException {
testSetMode();
testCases();
}
private void testSetMode() throws Exception {
private void testSetMode() throws SQLException {
deleteDb("mvcc1");
c1 = getConnection("mvcc1;MVCC=FALSE");
Statement stat = c1.createStatement();
......@@ -47,7 +47,7 @@ public class TestMvcc1 extends TestBase {
c1.close();
}
private void testCases() throws Exception {
private void testCases() throws SQLException {
if (!config.mvcc) {
return;
}
......
......@@ -7,6 +7,7 @@
package org.h2.test.mvcc;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import org.h2.test.TestBase;
......@@ -21,7 +22,7 @@ public class TestMvcc2 extends TestBase {
private static final String INSERT = "INSERT INTO EMPLOYEE (id, version, NAME) VALUES (1, 1, 'Jones')";
private static final String UPDATE = "UPDATE EMPLOYEE SET NAME = 'Miller' WHERE version = 1";
public void test() throws Exception {
public void test() throws SQLException {
if (!config.mvcc) {
return;
}
......@@ -30,11 +31,11 @@ public class TestMvcc2 extends TestBase {
testInsertRollback();
}
private Connection getConnection() throws Exception {
private Connection getConnection() throws SQLException {
return getConnection("mvcc2");
}
private void testInsertUpdateRollback() throws Exception {
private void testInsertUpdateRollback() throws SQLException {
Connection conn = getConnection();
conn.setAutoCommit(false);
Statement stmt = conn.createStatement();
......@@ -47,7 +48,7 @@ public class TestMvcc2 extends TestBase {
conn.close();
}
private void testInsertRollback() throws Exception {
private void testInsertRollback() throws SQLException {
Connection conn = getConnection();
conn.setAutoCommit(false);
Statement stmt = conn.createStatement();
......
......@@ -8,6 +8,7 @@ package org.h2.test.mvcc;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import org.h2.test.TestBase;
......@@ -17,14 +18,14 @@ import org.h2.test.TestBase;
*/
public class TestMvcc3 extends TestBase {
public void test() throws Exception {
public void test() throws SQLException {
testCreateTableAsSelect();
testSequence();
testDisableAutoCommit();
testRollback();
}
private void testCreateTableAsSelect() throws Exception {
private void testCreateTableAsSelect() throws SQLException {
if (!config.mvcc) {
return;
}
......@@ -41,7 +42,7 @@ public class TestMvcc3 extends TestBase {
c2.close();
}
private void testRollback() throws Exception {
private void testRollback() throws SQLException {
if (!config.mvcc) {
return;
}
......@@ -89,7 +90,7 @@ public class TestMvcc3 extends TestBase {
conn2.close();
}
private void testDisableAutoCommit() throws Exception {
private void testDisableAutoCommit() throws SQLException {
if (!config.mvcc) {
return;
}
......@@ -108,7 +109,7 @@ public class TestMvcc3 extends TestBase {
conn.close();
}
private void testSequence() throws Exception {
private void testSequence() throws SQLException {
if (config.memory) {
return;
}
......
......@@ -25,11 +25,11 @@ public class Listener implements Runnable {
*
* @param args the command line parameters
*/
public static void main(String[] args) throws Exception {
public static void main(String[] args) throws IOException {
new Listener().test(args);
}
private void test(String[] args) throws Exception {
private void test(String[] args) throws IOException {
int port = 9099;
for (int i = 0; i < args.length; i++) {
if (args[i].equals("-port")) {
......@@ -50,7 +50,7 @@ public class Listener implements Runnable {
}
}
private void listen(int port) throws Exception {
private void listen(int port) throws IOException {
new Thread(this).start();
ServerSocket serverSocket = new ServerSocket(port);
System.out.println("Listening on " + serverSocket.toString());
......
......@@ -9,6 +9,7 @@ package org.h2.test.poweroff;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileDescriptor;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.net.Socket;
import java.sql.Connection;
......@@ -116,7 +117,7 @@ public class Test {
}
}
private void testFile(DataOutputStream out) throws Exception {
private void testFile(DataOutputStream out) throws IOException {
File file = new File("test.txt");
if (file.exists()) {
file.delete();
......
......@@ -81,7 +81,7 @@ public class TestRecover {
testLoop();
}
private static File backup(String sourcePath, String targetPath, String basePath, int max, String node) throws Exception {
private static File backup(String sourcePath, String targetPath, String basePath, int max, String node) throws IOException {
File root = new File(targetPath);
if (!root.exists()) {
root.mkdirs();
......
......@@ -39,7 +39,7 @@ public class TestRowLocks extends TestBase {
testCases();
}
private void testSetMode() throws Exception {
private void testSetMode() throws SQLException {
deleteDb("rowLocks");
c1 = getConnection("rowLocks");
Statement stat = c1.createStatement();
......@@ -102,7 +102,7 @@ public class TestRowLocks extends TestBase {
c2.close();
}
private String getSingleValue(Statement stat, String sql) throws Exception {
private String getSingleValue(Statement stat, String sql) throws SQLException {
ResultSet rs = stat.executeQuery(sql);
return rs.next() ? rs.getString(1) : null;
}
......
......@@ -19,7 +19,7 @@ import org.h2.test.TestBase;
*/
public class TestNestedLoop extends TestBase {
public void test() throws Exception {
public void test() throws SQLException {
deleteDb("nestedLoop");
Connection conn = getConnection("nestedLoop");
Statement stat = conn.createStatement();
......
......@@ -23,7 +23,7 @@ import org.h2.tools.Server;
*/
public class TestPgServer extends TestBase {
public void test() throws Exception {
public void test() throws SQLException {
deleteDb("test");
Server server = Server.createPgServer(new String[]{"-baseDir", baseDir, "-pgPort", "5535"});
server.start();
......@@ -37,7 +37,7 @@ public class TestPgServer extends TestBase {
}
}
private void testPgClient() throws Exception {
private void testPgClient() throws SQLException {
Connection conn = DriverManager.getConnection("jdbc:postgresql://localhost:5535/test", "sa", "sa");
Statement stat = conn.createStatement();
try {
......
......@@ -22,7 +22,7 @@ import org.h2.tools.DeleteDbFiles;
*/
public class TestBtreeIndex extends TestBase {
public void test() throws Exception {
public void test() throws SQLException {
Random random = new Random();
while (true) {
int seed = random.nextInt();
......@@ -30,15 +30,15 @@ public class TestBtreeIndex extends TestBase {
}
}
public void testCase(int seed) throws Exception {
public void testCase(int seed) throws SQLException {
String old = baseDir;
baseDir = TestBase.getTestDir("index");
testOne(seed);
baseDir = old;
}
private void testOne(int seed) throws Exception {
Class.forName("org.h2.Driver");
private void testOne(int seed) throws SQLException {
org.h2.Driver.load();
printTime("testIndex " + seed);
Random random = new Random(seed);
int distinct, prefixLength;
......
......@@ -65,7 +65,7 @@ public class TestCrashAPI extends TestBase {
}
}
private Connection getConnection(int seed, boolean delete) throws Exception {
private Connection getConnection(int seed, boolean delete) throws SQLException {
openCount++;
if (delete) {
deleteDb();
......@@ -148,7 +148,7 @@ public class TestCrashAPI extends TestBase {
return conn;
}
private void testOne(int seed) throws Exception {
private void testOne(int seed) throws SQLException {
printTime("seed: " + seed);
callCount = 0;
openCount = 0;
......@@ -239,7 +239,7 @@ public class TestCrashAPI extends TestBase {
" " + t.getMessage(), t);
}
private Object callRandom(int seed, int id, int objectId, Object o, Method m) throws Exception {
private Object callRandom(int seed, int id, int objectId, Object o, Method m) throws SQLException {
Class[] paramClasses = m.getParameterTypes();
Object[] params = new Object[paramClasses.length];
for (int i = 0; i < params.length; i++) {
......@@ -399,12 +399,12 @@ public class TestCrashAPI extends TestBase {
TestScript script = new TestScript();
ArrayList add = script.getAllStatements(config, "org/h2/test/test.in.txt");
initMethods();
Class.forName("org.h2.Driver");
org.h2.Driver.load();
statements.addAll(add);
return this;
}
public void testCase(int i) throws Exception {
public void testCase(int i) throws SQLException {
int old = SysProperties.getMaxQueryTimeout();
String oldBaseDir = baseDir;
try {
......@@ -417,7 +417,7 @@ public class TestCrashAPI extends TestBase {
}
}
public void test() throws Exception {
public void test() throws SQLException {
if (config.mvcc || config.networked || config.logMode == 0) {
return;
}
......
......@@ -13,6 +13,7 @@ import java.io.InputStream;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;
......@@ -99,12 +100,12 @@ public abstract class TestHalt extends TestBase {
/**
* Initialize the test.
*/
abstract void testInit() throws Exception;
abstract void testInit() throws SQLException;
/**
* Check if the database is consistent after a simulated database crash.
*/
abstract void testCheckAfterCrash() throws Exception;
abstract void testCheckAfterCrash() throws SQLException;
/**
* Wait for some time after the application has been started.
......@@ -114,15 +115,14 @@ public abstract class TestHalt extends TestBase {
/**
* Start the application.
*/
abstract void appStart() throws Exception;
abstract void appStart() throws SQLException;
/**
* Run the application.
* @throws Exception
*/
abstract void appRun() throws Exception;
abstract void appRun() throws SQLException;
public void test() throws Exception {
public void test() throws SQLException {
for (int i = 0;; i++) {
operations = OP_INSERT | i;
flags = i >> 4;
......@@ -136,8 +136,8 @@ public abstract class TestHalt extends TestBase {
}
}
Connection getConnection() throws Exception {
Class.forName("org.h2.Driver");
Connection getConnection() throws SQLException {
org.h2.Driver.load();
return DriverManager.getConnection("jdbc:h2:" + baseDir + "/halt", "sa", "sa");
}
......@@ -157,7 +157,7 @@ public abstract class TestHalt extends TestBase {
}
}
private void runRandom() throws Exception {
private void runRandom() throws SQLException {
connect();
try {
traceOperation("connected, operations:" + operations + " flags:" + flags + " value:" + value);
......@@ -173,11 +173,11 @@ public abstract class TestHalt extends TestBase {
disconnect();
}
private void connect() throws Exception {
private void connect() throws SQLException {
try {
traceOperation("connecting");
conn = getConnection();
} catch (Exception e) {
} catch (SQLException e) {
trace("connect", e);
e.printStackTrace();
throw e;
......@@ -287,7 +287,7 @@ public abstract class TestHalt extends TestBase {
}
}
// public Connection getConnectionHSQLDB() throws Exception {
// public Connection getConnectionHSQLDB() throws SQLException {
// File lock = new File("test.lck");
// while (lock.exists()) {
// lock.delete();
......@@ -297,7 +297,7 @@ public abstract class TestHalt extends TestBase {
// return DriverManager.getConnection("jdbc:hsqldb:test", "sa", "");
// }
// public Connection getConnectionDerby() throws Exception {
// public Connection getConnectionDerby() throws SQLException {
// File lock = new File("test3/db.lck");
// while (lock.exists()) {
// lock.delete();
......
......@@ -69,9 +69,9 @@ public class TestHaltApp extends TestHalt {
* This method is called after a simulated crash. The method should check if
* the data is transactionally consistent and throw an exception if not.
*
* @throws Exception if the data is not consistent.
* @throws SQLException if the data is not consistent.
*/
protected void testCheckAfterCrash() throws Exception {
protected void testCheckAfterCrash() throws SQLException {
Statement stat = conn.createStatement();
ResultSet rs = stat.executeQuery("SELECT COUNT(*) FROM TEST");
rs.next();
......@@ -79,7 +79,7 @@ public class TestHaltApp extends TestHalt {
System.out.println("count: " + count);
if (count % 2 == 1) {
traceOperation("row count: " + count);
throw new Exception("Unexpected odd row count");
throw new SQLException("Unexpected odd row count");
}
}
......@@ -101,7 +101,7 @@ public class TestHaltApp extends TestHalt {
/**
* Run the application code.
*/
protected void appRun() throws Exception {
protected void appRun() throws SQLException {
conn.setAutoCommit(false);
traceOperation("setAutoCommit false");
int rows = 10000 + value;
......
......@@ -226,11 +226,11 @@ public class TestJoin extends TestBase {
buff.append(" ");
}
private void execute(String sql, Object[] params) throws Exception {
private void execute(String sql, Object[] params) throws SQLException {
execute(sql, params, false);
}
private void execute(String sql, Object[] params, boolean ignoreDifference) throws Exception {
private void execute(String sql, Object[] params, boolean ignoreDifference) throws SQLException {
String first = null;
for (int i = 0; i < connections.size(); i++) {
Connection conn = (Connection) connections.get(i);
......@@ -262,7 +262,7 @@ public class TestJoin extends TestBase {
first = s;
} else {
if (!ignoreDifference && !s.equals(first)) {
throw new Exception("FAIL s:" + s + " first:" + first + " sql:" + sql);
fail("FAIL s:" + s + " first:" + first + " sql:" + sql);
}
}
}
......
......@@ -102,7 +102,7 @@ public class TestKill extends TestBase {
}
}
private void checkData() throws Exception {
private void checkData() throws SQLException {
trace("checkData...");
ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM ACCOUNT ORDER BY ID");
PreparedStatement prep = conn.prepareStatement("SELECT SUM(AMOUNT) FROM LOG WHERE ACCOUNTID=?");
......
......@@ -9,6 +9,7 @@ package org.h2.test.synth;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Random;
......@@ -30,7 +31,7 @@ public class TestKillProcess {
*
* @param args the command line parameters
*/
public static void main(String[] args) throws Exception {
public static void main(String[] args) throws SQLException {
SelfDestructor.startCountdown(60);
try {
Class.forName("org.h2.Driver");
......
......@@ -11,6 +11,7 @@ import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Random;
......@@ -68,7 +69,7 @@ public class TestKillRestart extends TestBase {
*
* @param args the command line parameters
*/
public static void main(String[] args) throws Exception {
public static void main(String[] args) throws SQLException {
SelfDestructor.startCountdown(60);
String driver = "org.h2.Driver";
String url = "jdbc:h2:test", user = "sa", password = "sa";
......
......@@ -119,12 +119,12 @@ public class TestKillRestartMulti extends TestBase {
*
* @param args the command line parameters
*/
public static void main(String[] args) throws Exception {
public static void main(String[] args) throws SQLException {
SelfDestructor.startCountdown(60);
new TestKillRestartMulti().test(args);
}
private void test(String[] args) throws Exception {
private void test(String[] args) throws SQLException {
for (int i = 0; i < args.length; i++) {
if ("-url".equals(args[i])) {
url = args[++i];
......@@ -235,7 +235,7 @@ public class TestKillRestartMulti extends TestBase {
return conn;
}
private void createTable(Random random) throws Exception {
private void createTable(Random random) throws SQLException {
Connection conn = (Connection) connections.get(random.nextInt(connections.size()));
Statement stat = conn.createStatement();
String table = "TEST" + random.nextInt(10);
......@@ -256,7 +256,7 @@ public class TestKillRestartMulti extends TestBase {
}
}
private void testConsistent(Connection conn) throws Exception {
private void testConsistent(Connection conn) throws SQLException {
for (int i = 0; i < 20; i++) {
Statement stat = conn.createStatement();
try {
......
......@@ -50,7 +50,7 @@ public class TestRandomSQL extends TestBase {
// return "dataRandomSQL/randomSql" + dbId+";TRACE_LEVEL_FILE=3";
}
private Connection connect() throws Exception {
private Connection connect() throws SQLException {
while (true) {
try {
return getConnection(getDatabaseName());
......@@ -122,7 +122,7 @@ public class TestRandomSQL extends TestBase {
return this;
}
private void testWithSeed(Bnf config) throws Exception {
private void testWithSeed(Bnf config) throws SQLException {
config.getRandom().setSeed(seed);
Connection conn = null;
try {
......@@ -164,7 +164,7 @@ public class TestRandomSQL extends TestBase {
}
}
public void testCase(int i) throws Exception {
public void testCase(int i) throws SQLException {
String old = SysProperties.scriptDirectory;
SysProperties.scriptDirectory = "dataScript/";
seed = i;
......@@ -178,7 +178,7 @@ public class TestRandomSQL extends TestBase {
SysProperties.scriptDirectory = old;
}
public void test() throws Exception {
public void test() throws SQLException {
if (config.networked) {
return;
}
......
......@@ -24,7 +24,7 @@ public class TestSimpleIndex extends TestBase {
private Statement stat;
private RandomGen random;
public void test() throws Exception {
public void test() throws SQLException {
deleteDb("simpleIndex");
conn = getConnection("simpleIndex");
random = new RandomGen();
......@@ -34,7 +34,7 @@ public class TestSimpleIndex extends TestBase {
}
}
private void testIndex(int seed) throws Exception {
private void testIndex(int seed) throws SQLException {
random.setSeed(seed);
String unique = random.nextBoolean() ? "UNIQUE " : "";
int len = random.getInt(2) + 1;
......@@ -64,7 +64,7 @@ public class TestSimpleIndex extends TestBase {
execute("DROP TABLE TEST_DI");
}
private void testRows() throws Exception {
private void testRows() throws SQLException {
String a = randomValue(), b = randomValue(), c = randomValue();
String data = a + "/" + b + "/" + c;
String sql = "VALUES(" + a + ", " + b + ", " + c + ", '" + data + "')";
......@@ -138,7 +138,7 @@ public class TestSimpleIndex extends TestBase {
assertEquals(r1, r4);
}
private String getResult(String sql) throws Exception {
private String getResult(String sql) throws SQLException {
ResultSet rs = stat.executeQuery(sql);
StringBuffer buff = new StringBuffer();
while (rs.next()) {
......@@ -153,7 +153,7 @@ public class TestSimpleIndex extends TestBase {
return random.getInt(10) == 0 ? "NULL" : "" + (random.getInt(100) - 50);
}
private void execute(String sql) throws Exception {
private void execute(String sql) throws SQLException {
try {
println(sql + ";");
stat.execute(sql);
......
......@@ -9,6 +9,7 @@ package org.h2.test.synth;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Random;
......@@ -78,7 +79,7 @@ public class TestThreads extends TestBase implements Runnable {
conn.close();
}
private void insertRows(Connection conn, String tableName, int len) throws Exception {
private void insertRows(Connection conn, String tableName, int len) throws SQLException {
PreparedStatement prep = conn.prepareStatement("INSERT INTO " + tableName + " VALUES(?, 'Hi')");
for (int i = 0; i < len; i++) {
prep.setInt(1, i);
......@@ -86,7 +87,7 @@ public class TestThreads extends TestBase implements Runnable {
}
}
private void checkTable(Connection conn, String tableName) throws Exception {
private void checkTable(Connection conn, String tableName) throws SQLException {
Statement stat = conn.createStatement();
ResultSet rs = stat.executeQuery("SELECT * FROM " + tableName + " ORDER BY ID");
while (rs.next()) {
......
......@@ -24,13 +24,13 @@ import org.h2.tools.DeleteDbFiles;
*/
public class TestTimer extends TestBase {
public void test() throws Exception {
public void test() throws SQLException {
validateOld();
DeleteDbFiles.execute(baseDir, "timer", true);
loop();
}
private void loop() throws Exception {
private void loop() throws SQLException {
println("loop");
Connection conn = getConnection("timer");
Statement stat = conn.createStatement();
......
......@@ -280,7 +280,7 @@ public class TestSynth extends TestBase {
// "");
mode = H2_MEM;
Class.forName("org.h2.Driver");
org.h2.Driver.load();
addDatabase("org.h2.Driver", "jdbc:h2:mem:synth", "sa", "", true);
addDatabase("org.h2.Driver", "jdbc:h2:" + baseDir + "/" + DIR + "/synth", "sa", "", false);
......
......@@ -23,7 +23,7 @@ public class TestMulti extends TestBase {
public volatile boolean stop;
public void test() throws Exception {
Class.forName("org.h2.Driver");
org.h2.Driver.load();
deleteDb(baseDir, "openClose");
// int len = getSize(5, 100);
......
......@@ -77,7 +77,7 @@ public class TestMultiNews extends TestMultiThread {
conn.close();
}
void finalTest() throws Exception {
void finalTest() throws SQLException {
// nothing to do
}
......
......@@ -132,7 +132,7 @@ public class TestMultiOrder extends TestMultiThread {
conn.close();
}
void finalTest() throws Exception {
void finalTest() throws SQLException {
conn = base.getConnection();
ResultSet rs = conn.createStatement().executeQuery("select count(*) from customer");
rs.next();
......
......@@ -54,9 +54,9 @@ abstract class TestMultiThread extends Thread {
/**
* This method is called once after all threads have been stopped.
* @throws Exception
* @throws SQLException
*/
abstract void finalTest() throws Exception;
abstract void finalTest() throws SQLException;
public void run() {
try {
......
......@@ -62,7 +62,7 @@ public class Player {
*
* @param args the arguments of the application
*/
public static void main(String[] args) throws Exception {
public static void main(String[] args) throws IOException {
new Player().run(args);
}
......
......@@ -70,7 +70,7 @@ public class TestExit extends TestBase implements DatabaseEventListener {
*
* @param args the command line parameters
*/
public static void main(String[] args) throws Exception {
public static void main(String[] args) throws SQLException {
SelfDestructor.startCountdown(60);
if (args.length == 0) {
System.exit(1);
......@@ -80,8 +80,8 @@ public class TestExit extends TestBase implements DatabaseEventListener {
app.execute(action);
}
private void execute(int action) throws Exception {
Class.forName("org.h2.Driver");
private void execute(int action) throws SQLException {
org.h2.Driver.load();
String url = "";
switch (action) {
case OPEN_WITH_CLOSE_ON_EXIT:
......@@ -99,7 +99,7 @@ public class TestExit extends TestBase implements DatabaseEventListener {
conn2.close();
}
private static Connection open(String url) throws Exception {
private static Connection open(String url) throws SQLException {
getClosedFile().delete();
return DriverManager.getConnection(url, "sa", "");
}
......
......@@ -6,6 +6,8 @@
*/
package org.h2.test.unit;
import java.sql.SQLException;
import org.h2.expression.CompareLike;
import org.h2.test.TestBase;
import org.h2.value.CompareMode;
......@@ -15,7 +17,7 @@ import org.h2.value.CompareMode;
*/
public class TestPattern extends TestBase {
public void test() throws Exception {
public void test() throws SQLException {
CompareMode mode = new CompareMode(null, null, 100);
CompareLike comp = new CompareLike(mode, null, null, null, false);
test(comp, "B", "%_");
......@@ -30,7 +32,7 @@ public class TestPattern extends TestBase {
}
}
private void test(CompareLike comp, String value, String pattern) throws Exception {
private void test(CompareLike comp, String value, String pattern) throws SQLException {
String regexp = initPatternRegexp(pattern, '\\');
boolean resultRegexp = value.matches(regexp);
boolean result = comp.test(pattern, value, '\\');
......@@ -65,7 +67,7 @@ public class TestPattern extends TestBase {
return buff.toString();
}
private String initPatternRegexp(String pattern, char escape) throws Exception {
private String initPatternRegexp(String pattern, char escape) {
int len = pattern.length();
StringBuffer buff = new StringBuffer();
for (int i = 0; i < len; i++) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论