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

Cleanup:

- Let it compile with JDK 5
上级 dd7cdf0d
...@@ -14,6 +14,7 @@ import java.sql.SQLException; ...@@ -14,6 +14,7 @@ import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
...@@ -27,6 +28,7 @@ import org.h2.jaqu.util.JdbcUtils; ...@@ -27,6 +28,7 @@ import org.h2.jaqu.util.JdbcUtils;
import org.h2.jaqu.util.StringUtils; import org.h2.jaqu.util.StringUtils;
import org.h2.jaqu.util.Utils; import org.h2.jaqu.util.Utils;
import org.h2.jaqu.util.WeakIdentityHashMap; import org.h2.jaqu.util.WeakIdentityHashMap;
//## Java 1.5 end ##
/** /**
* This class represents a connection to a database. * This class represents a connection to a database.
...@@ -48,7 +50,9 @@ public class Db { ...@@ -48,7 +50,9 @@ public class Db {
Utils.newHashMap(); Utils.newHashMap();
private final SQLDialect dialect; private final SQLDialect dialect;
private DbUpgrader dbUpgrader = new DefaultDbUpgrader(); private DbUpgrader dbUpgrader = new DefaultDbUpgrader();
private final Set<Class<?>> upgradeChecked = Utils.newConcurrentHashSet(); private final Set<Class<?>> upgradeChecked = Collections.synchronizedSet(new HashSet<Class<?>>());
private int todoDocumentNewFeaturesInHtmlFile;
public Db(Connection conn) { public Db(Connection conn) {
this.conn = conn; this.conn = conn;
...@@ -56,6 +60,7 @@ public class Db { ...@@ -56,6 +60,7 @@ public class Db {
} }
SQLDialect getDialect(String clazz) { SQLDialect getDialect(String clazz) {
int todo;
// TODO add special cases here // TODO add special cases here
return new DefaultSQLDialect(); return new DefaultSQLDialect();
} }
...@@ -119,6 +124,7 @@ public class Db { ...@@ -119,6 +124,7 @@ public class Db {
public <T> void insert(T t) { public <T> void insert(T t) {
Class<?> clazz = t.getClass(); Class<?> clazz = t.getClass();
int upgradeDbSoundsWrongHere;
upgradeDb().define(clazz).createTableIfRequired(this).insert(this, t, false); upgradeDb().define(clazz).createTableIfRequired(this).insert(this, t, false);
} }
...@@ -295,10 +301,11 @@ public class Db { ...@@ -295,10 +301,11 @@ public class Db {
} }
} }
PreparedStatement prepare(String sql, boolean returnKey) { PreparedStatement prepare(String sql, boolean returnGeneratedKeys) {
try { try {
if (returnKey) if (returnGeneratedKeys) {
return conn.prepareStatement(sql, PreparedStatement.RETURN_GENERATED_KEYS); return conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
}
return conn.prepareStatement(sql); return conn.prepareStatement(sql);
} catch (SQLException e) { } catch (SQLException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
......
...@@ -21,10 +21,10 @@ import java.util.regex.Matcher; ...@@ -21,10 +21,10 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.h2.jaqu.Db; import org.h2.jaqu.Db;
import org.h2.jaqu.DbInspector; import org.h2.jaqu.DbInspector;
import org.h2.message.DbException;
/** /**
* Generates JaQu models. * Generates JaQu models.
*
*/ */
public class GenerateModels { public class GenerateModels {
...@@ -130,10 +130,8 @@ public class GenerateModels { ...@@ -130,10 +130,8 @@ public class GenerateModels {
System.out.println("Generated " + classFile.getAbsolutePath()); System.out.println("Generated " + classFile.getAbsolutePath());
} }
} }
} catch (SQLException s) { } catch (IOException io) {
throw s; throw DbException.convertIOException(io, "could not generate model").getSQLException();
} catch (IOException i) {
throw new SQLException(i);
} finally { } finally {
JdbcUtils.closeSilently(conn); JdbcUtils.closeSilently(conn);
} }
......
...@@ -22,8 +22,6 @@ import java.util.HashSet; ...@@ -22,8 +22,6 @@ import java.util.HashSet;
import java.util.IdentityHashMap; import java.util.IdentityHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
//## Java 1.5 end ## //## Java 1.5 end ##
...@@ -55,10 +53,6 @@ public class Utils { ...@@ -55,10 +53,6 @@ public class Utils {
return new HashSet<T>(list); return new HashSet<T>(list);
} }
public static <T> Set<T> newConcurrentHashSet() {
return Collections.newSetFromMap(new ConcurrentHashMap<T, Boolean>());
}
public static <A, B> HashMap<A, B> newHashMap() { public static <A, B> HashMap<A, B> newHashMap() {
return new HashMap<A, B>(); return new HashMap<A, B>();
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论