提交 0ea30d28 authored 作者: Thomas Mueller's avatar Thomas Mueller

--no commit message

--no commit message
上级 6f67c668
...@@ -106,12 +106,12 @@ public class H2Dictionary extends DBDictionary { ...@@ -106,12 +106,12 @@ public class H2Dictionary extends DBDictionary {
buf.append(", ").append(pkStr); buf.append(", ").append(pkStr);
} }
Unique[] unqs = table.getUniques(); Unique[] uniques = table.getUniques();
String unqStr; String uniqueStr;
for (int i = 0; i < unqs.length; i++) { for (int i = 0; i < uniques.length; i++) {
unqStr = getUniqueConstraintSQL(unqs[i]); uniqueStr = getUniqueConstraintSQL(uniques[i]);
if (unqStr != null) if (uniqueStr != null)
buf.append(", ").append(unqStr); buf.append(", ").append(uniqueStr);
} }
buf.append(")"); buf.append(")");
...@@ -154,12 +154,12 @@ public class H2Dictionary extends DBDictionary { ...@@ -154,12 +154,12 @@ public class H2Dictionary extends DBDictionary {
return cols; return cols;
} }
public void setDouble(PreparedStatement stmnt, int idx, double val, Column col) throws SQLException { public void setDouble(PreparedStatement stat, int idx, double val, Column col) throws SQLException {
super.setDouble(stmnt, idx, val, col); super.setDouble(stat, idx, val, col);
} }
public void setBigDecimal(PreparedStatement stmnt, int idx, BigDecimal val, Column col) throws SQLException { public void setBigDecimal(PreparedStatement stat, int idx, BigDecimal val, Column col) throws SQLException {
super.setBigDecimal(stmnt, idx, val, col); super.setBigDecimal(stat, idx, val, col);
} }
protected void appendSelectRange(SQLBuffer buf, long start, long end) { protected void appendSelectRange(SQLBuffer buf, long start, long end) {
......
...@@ -68,8 +68,8 @@ public class CodeSwitch { ...@@ -68,8 +68,8 @@ public class CodeSwitch {
System.out.println("labels in the source code are shown."); System.out.println("labels in the source code are shown.");
System.out.println("-r+ recurse subdirectories (default)"); System.out.println("-r+ recurse subdirectories (default)");
System.out.println("-r- do not recurse subdirectories"); System.out.println("-r- do not recurse subdirectories");
System.out.println("Use +MODE to switch on the things labeld MODE"); System.out.println("Use +MODE to switch on code labeled MODE");
System.out.println("Use -MODE to switch off the things labeld MODE"); System.out.println("Use -MODE to switch off code labeled MODE");
System.out System.out
.println("Path: Any number of path or files may be specified."); .println("Path: Any number of path or files may be specified.");
System.out System.out
...@@ -164,7 +164,7 @@ public class CodeSwitch { ...@@ -164,7 +164,7 @@ public class CodeSwitch {
private boolean processFile(String name) { private boolean processFile(String name) {
File f = new File(name); File f = new File(name);
boolean switchoff = false; boolean off = false;
boolean working = false; boolean working = false;
int state = 0; int state = 0;
try { try {
...@@ -233,11 +233,11 @@ public class CodeSwitch { ...@@ -233,11 +233,11 @@ public class CodeSwitch {
} }
if (switchedOn) { if (switchedOn) {
working = true; working = true;
switchoff = false; off = false;
} else if (switchedOff) { } else if (switchedOff) {
working = true; working = true;
insertLine(++i, "/*" + endOfLine); insertLine(++i, "/*" + endOfLine);
switchoff = true; off = true;
} }
if (switches.indexOf(s) == -1) { if (switches.indexOf(s) == -1) {
switches.add(s); switches.add(s);
...@@ -249,12 +249,12 @@ public class CodeSwitch { ...@@ -249,12 +249,12 @@ public class CodeSwitch {
} }
state = 2; state = 2;
if (working) { if (working) {
if (switchoff) { if (off) {
insertLine(++i, "*/" + endOfLine); insertLine(++i, "*/" + endOfLine);
switchoff = false; off = false;
} else { } else {
insertLine(++i, "/*" + endOfLine); insertLine(++i, "/*" + endOfLine);
switchoff = true; off = true;
} }
} }
} else if (lineTrim.startsWith("//#endif")) { } else if (lineTrim.startsWith("//#endif")) {
...@@ -263,7 +263,7 @@ public class CodeSwitch { ...@@ -263,7 +263,7 @@ public class CodeSwitch {
return false; return false;
} }
state = 0; state = 0;
if (working && switchoff) { if (working && off) {
insertLine(i++, "*/" + endOfLine); insertLine(i++, "*/" + endOfLine);
} }
working = false; working = false;
...@@ -275,18 +275,18 @@ public class CodeSwitch { ...@@ -275,18 +275,18 @@ public class CodeSwitch {
return false; return false;
} }
if (changed) { if (changed) {
File fnew = new File(name + ".new"); File fileNew = new File(name + ".new");
FileWriter write = new FileWriter(fnew); FileWriter write = new FileWriter(fileNew);
for (int i = 0; i < lines.size(); i++) { for (int i = 0; i < lines.size(); i++) {
write.write(getLine(i)); write.write(getLine(i));
} }
write.close(); write.close();
File fbak = new File(name + ".bak"); File fileBack = new File(name + ".bak");
fbak.delete(); fileBack.delete();
f.renameTo(fbak); f.renameTo(fileBack);
File fcopy = new File(name); File fileCopy = new File(name);
fnew.renameTo(fcopy); fileNew.renameTo(fileCopy);
fbak.delete(); fileBack.delete();
System.out.println(name); System.out.println(name);
} }
return true; return true;
......
...@@ -12,13 +12,15 @@ import java.io.OutputStreamWriter; ...@@ -12,13 +12,15 @@ import java.io.OutputStreamWriter;
import java.io.RandomAccessFile; import java.io.RandomAccessFile;
import org.h2.server.web.PageParser; import org.h2.server.web.PageParser;
import org.h2.tools.indexer.HtmlConverter;
import org.h2.util.IOUtils; import org.h2.util.IOUtils;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
public class PropertiesToUTF8 { public class PropertiesToUTF8 {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
File[] list = new File("bin/org/h2/web/res").listFiles(); File[] list = new File("bin/org/h2/server/web/res").listFiles();
for(int i=0; i<list.length; i++) { for(int i=0; list != null && i<list.length; i++) {
File f = list[i]; File f = list[i];
if(!f.getName().endsWith(".properties")) { if(!f.getName().endsWith(".properties")) {
continue; continue;
...@@ -29,13 +31,14 @@ public class PropertiesToUTF8 { ...@@ -29,13 +31,14 @@ public class PropertiesToUTF8 {
in.close(); in.close();
String name = f.getName(); String name = f.getName();
if(name.startsWith("utf8")) { if(name.startsWith("utf8")) {
s = PageParser.escapeHtml(s, false); s = HtmlConverter.convertStringToHtml(s);
RandomAccessFile out = new RandomAccessFile(name.substring(4), "rw"); RandomAccessFile out = new RandomAccessFile(name.substring(4), "rw");
out.write(s.getBytes()); out.write(s.getBytes());
out.close(); out.close();
} else { } else {
new CheckTextFiles().checkOrFixFile(f, false, false); new CheckTextFiles().checkOrFixFile(f, false, false);
s = unescapeHtml(s); s = HtmlConverter.convertHtmlToString(s);
// s = unescapeHtml(s);
s = StringUtils.javaDecode(s); s = StringUtils.javaDecode(s);
FileOutputStream out = new FileOutputStream("utf8" + f.getName()); FileOutputStream out = new FileOutputStream("utf8" + f.getName());
OutputStreamWriter w = new OutputStreamWriter(out, "UTF-8"); OutputStreamWriter w = new OutputStreamWriter(out, "UTF-8");
......
...@@ -71,13 +71,13 @@ public class GenerateDoc { ...@@ -71,13 +71,13 @@ public class GenerateDoc {
} }
void process(String fileName) throws Exception { void process(String fileName) throws Exception {
FileOutputStream fout = new FileOutputStream(outDir + "/"+fileName+".html"); FileOutputStream out = new FileOutputStream(outDir + "/"+fileName+".html");
FileInputStream fin = new FileInputStream(inDir + "/"+fileName+".jsp"); FileInputStream in = new FileInputStream(inDir + "/"+fileName+".jsp");
byte[] bytes = IOUtils.readBytesAndClose(fin, 0); byte[] bytes = IOUtils.readBytesAndClose(in, 0);
String page = new String(bytes); String page = new String(bytes);
page = PageParser.parse(null, page, session); page = PageParser.parse(null, page, session);
fout.write(page.getBytes()); out.write(page.getBytes());
fout.close(); out.close();
} }
void map(String key, String sql) throws Exception { void map(String key, String sql) throws Exception {
......
...@@ -163,7 +163,7 @@ public class LinkChecker { ...@@ -163,7 +163,7 @@ public class LinkChecker {
} else if(type.equals("name")) { } else if(type.equals("name")) {
targets.put(path + "#" + ref, "name"); targets.put(path + "#" + ref, "name");
} else { } else {
error(fileName, "unsupported <a xxx: " + html.substring(idx, idx + 100)); error(fileName, "unsupported <a ?: " + html.substring(idx, idx + 100));
} }
} }
} }
......
...@@ -5,6 +5,7 @@ import java.io.FileReader; ...@@ -5,6 +5,7 @@ import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
import java.io.Reader; import java.io.Reader;
import java.io.StringWriter; import java.io.StringWriter;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
...@@ -18,6 +19,7 @@ public class SpellChecker { ...@@ -18,6 +19,7 @@ public class SpellChecker {
private HashSet used = new HashSet(); private HashSet used = new HashSet();
private HashMap unknown = new HashMap(); private HashMap unknown = new HashMap();
private boolean debug; private boolean debug;
private boolean printDictionary;
private boolean addToDictionary; private boolean addToDictionary;
private static final String[] SUFFIX = new String[]{"java", "sql", "cpp", "txt", "html", "xml", "jsp", "css", "bat", "nsi", "csv", "xml", "js", "def", "dev", "h", "Driver", "properties", "win", "task", "php", "" }; private static final String[] SUFFIX = new String[]{"java", "sql", "cpp", "txt", "html", "xml", "jsp", "css", "bat", "nsi", "csv", "xml", "js", "def", "dev", "h", "Driver", "properties", "win", "task", "php", "" };
private static final String[] IGNORE = new String[]{"gif", "png", "odg", "ico", "sxd", "zip", "bz2", "rc", "layout", "res", "dll", "jar"}; private static final String[] IGNORE = new String[]{"gif", "png", "odg", "ico", "sxd", "zip", "bz2", "rc", "layout", "res", "dll", "jar"};
...@@ -30,13 +32,29 @@ public class SpellChecker { ...@@ -30,13 +32,29 @@ public class SpellChecker {
private void run(String dictionary, String dir) throws IOException { private void run(String dictionary, String dir) throws IOException {
process(new File(dir + "/" + dictionary)); process(new File(dir + "/" + dictionary));
process(new File(dir)); process(new File(dir));
System.out.println("used words"); if(printDictionary) {
for(Iterator it = used.iterator(); it.hasNext();) { System.out.println("USED WORDS");
String s = (String) it.next(); String[] list = new String[used.size()];
System.out.print(s + " "); used.toArray(list);
Arrays.sort(list);
StringBuffer buff = new StringBuffer();
for(int i=0; i<list.length; i++) {
String s = list[i];
if(buff.length() > 0) {
if(buff.length() + s.length() > 80) {
System.out.println(buff.toString());
buff.setLength(0);
} else {
buff.append(' ');
}
}
buff.append(s);
} }
System.out.println(buff.toString());
}
if(unknown.size() > 0) {
System.out.println(); System.out.println();
System.out.println("ALL UNKNOWN ----------------------------"); System.out.println("UNKNOWN WORDS");
for(Iterator it = unknown.keySet().iterator(); it.hasNext();) { for(Iterator it = unknown.keySet().iterator(); it.hasNext();) {
String s = (String) it.next(); String s = (String) it.next();
int count = ((Integer) unknown.get(s)).intValue(); int count = ((Integer) unknown.get(s)).intValue();
...@@ -45,7 +63,6 @@ public class SpellChecker { ...@@ -45,7 +63,6 @@ public class SpellChecker {
} }
} }
System.out.println(); System.out.println();
if(unknown.size() > 0) {
throw new IOException("spell check failed"); throw new IOException("spell check failed");
} }
} }
...@@ -57,9 +74,9 @@ public class SpellChecker { ...@@ -57,9 +74,9 @@ public class SpellChecker {
} }
int removeThisLater; int removeThisLater;
if(name.indexOf("\\test\\") >= 0) { // if(name.indexOf("\\test\\") >= 0) {
return; // return;
} // }
if(file.isDirectory()) { if(file.isDirectory()) {
File[] list = file.listFiles(); File[] list = file.listFiles();
...@@ -115,7 +132,7 @@ public class SpellChecker { ...@@ -115,7 +132,7 @@ public class SpellChecker {
} }
private void scan(String fileName, String text) { private void scan(String fileName, String text) {
HashSet notfound = new HashSet(); HashSet notFound = new HashSet();
StringTokenizer tokenizer = new StringTokenizer(text, "\r\n \t+\"*%&/()='[]{},.-;:_<>\\!?$@#|~^`"); StringTokenizer tokenizer = new StringTokenizer(text, "\r\n \t+\"*%&/()='[]{},.-;:_<>\\!?$@#|~^`");
while(tokenizer.hasMoreTokens()) { while(tokenizer.hasMoreTokens()) {
String token = tokenizer.nextToken(); String token = tokenizer.nextToken();
...@@ -126,17 +143,17 @@ public class SpellChecker { ...@@ -126,17 +143,17 @@ public class SpellChecker {
if(!addToDictionary && debug) { if(!addToDictionary && debug) {
System.out.print(token + " "); System.out.print(token + " ");
} }
scanCombinedToken(notfound, token); scanCombinedToken(notFound, token);
if(!addToDictionary && debug) { if(!addToDictionary && debug) {
System.out.println(); System.out.println();
} }
} }
if(notfound.isEmpty()) { if(notFound.isEmpty()) {
return; return;
} }
if(notfound.size() > 0) { if(notFound.size() > 0) {
System.out.println("file: " + fileName); System.out.println("file: " + fileName);
for(Iterator it = notfound.iterator(); it.hasNext();) { for(Iterator it = notFound.iterator(); it.hasNext();) {
String s = (String) it.next(); String s = (String) it.next();
System.out.print(s + " "); System.out.print(s + " ");
} }
...@@ -144,24 +161,24 @@ public class SpellChecker { ...@@ -144,24 +161,24 @@ public class SpellChecker {
} }
} }
private void scanCombinedToken(HashSet notfound, String token) { private void scanCombinedToken(HashSet notFound, String token) {
for(int i=1; i<token.length(); i++) { for(int i=1; i<token.length(); i++) {
char cleft = token.charAt(i-1); char charLeft = token.charAt(i-1);
char cright = token.charAt(i); char charRight = token.charAt(i);
if(Character.isLowerCase(cleft) && Character.isUpperCase(cright)) { if(Character.isLowerCase(charLeft) && Character.isUpperCase(charRight)) {
scanToken(notfound, token.substring(0, i)); scanToken(notFound, token.substring(0, i));
token = token.substring(i); token = token.substring(i);
i = 1; i = 1;
} else if(Character.isUpperCase(cleft) && Character.isLowerCase(cright)) { } else if(Character.isUpperCase(charLeft) && Character.isLowerCase(charRight)) {
scanToken(notfound, token.substring(0, i - 1)); scanToken(notFound, token.substring(0, i - 1));
token = token.substring(i - 1); token = token.substring(i - 1);
i = 1; i = 1;
} }
} }
scanToken(notfound, token); scanToken(notFound, token);
} }
private void scanToken(HashSet notfound, String token) { private void scanToken(HashSet notFound, String token) {
if(token.length() < 3) { if(token.length() < 3) {
return; return;
} }
...@@ -188,7 +205,7 @@ public class SpellChecker { ...@@ -188,7 +205,7 @@ public class SpellChecker {
dictionary.add(token); dictionary.add(token);
} else { } else {
if(!dictionary.contains(token)) { if(!dictionary.contains(token)) {
notfound.add(token); notFound.add(token);
increment(unknown, token); increment(unknown, token);
} else { } else {
used.add(token); used.add(token);
......
...@@ -89,7 +89,7 @@ public class XMLChecker { ...@@ -89,7 +89,7 @@ public class XMLChecker {
private static void checkXML(String xml, boolean html) throws Exception { private static void checkXML(String xml, boolean html) throws Exception {
String lastElement = null; String lastElement = null;
String[] noclose = new String[]{ String[] noClose = new String[]{
"li", "link", "meta", "br", "img", "input", "hr", "frame" "li", "link", "meta", "br", "img", "input", "hr", "frame"
}; };
XMLParser parser = new XMLParser(xml); XMLParser parser = new XMLParser(xml);
...@@ -110,8 +110,8 @@ public class XMLChecker { ...@@ -110,8 +110,8 @@ public class XMLChecker {
if(html && name.equals("table") && lastElement.trim().length() > 0) { if(html && name.equals("table") && lastElement.trim().length() > 0) {
throw new Exception("Test before table: " + lastElement); throw new Exception("Test before table: " + lastElement);
} }
for(int i=0; html && i<noclose.length; i++) { for(int i=0; html && i<noClose.length; i++) {
if(name.equals(noclose[i])) { if(name.equals(noClose[i])) {
name = null; name = null;
break; break;
} }
...@@ -121,8 +121,8 @@ public class XMLChecker { ...@@ -121,8 +121,8 @@ public class XMLChecker {
} }
} else if(event == XMLParser.END_ELEMENT) { } else if(event == XMLParser.END_ELEMENT) {
String name = parser.getName(); String name = parser.getName();
for(int i=0; html && i<noclose.length; i++) { for(int i=0; html && i<noClose.length; i++) {
if(name.equals(noclose[i])) { if(name.equals(noClose[i])) {
throw new Exception("Unnecessary closing element " + name + " at " + parser.getRemaining()); throw new Exception("Unnecessary closing element " + name + " at " + parser.getRemaining());
} }
} }
......
...@@ -8,6 +8,7 @@ import java.util.HashMap; ...@@ -8,6 +8,7 @@ import java.util.HashMap;
public class HtmlConverter { public class HtmlConverter {
private static HashMap charMap = new HashMap(); private static HashMap charMap = new HashMap();
private static HashMap codeMap = new HashMap();
private static final String[] CHARS = { private static final String[] CHARS = {
"quot:34", "amp:38", "lt:60", "gt:62", "nbsp:160", "iexcl:161", "cent:162", "quot:34", "amp:38", "lt:60", "gt:62", "nbsp:160", "iexcl:161", "cent:162",
...@@ -58,11 +59,43 @@ public class HtmlConverter { ...@@ -58,11 +59,43 @@ public class HtmlConverter {
int idx = token.indexOf(':'); int idx = token.indexOf(':');
String key = token.substring(0, idx); String key = token.substring(0, idx);
int ch = Integer.parseInt(token.substring(idx+1)); int ch = Integer.parseInt(token.substring(idx+1));
charMap.put(key, new Character((char)ch)); Character character = new Character((char)ch);
charMap.put(key, character);
codeMap.put(character, key);
} }
} }
public static String convertHtml(String html) { public static String convertStringToHtml(String s) {
if(s == null) {
return null;
}
if(s.length() == 0) {
return s;
}
StringBuffer buff = new StringBuffer();
for(int i=0; i<s.length(); i++) {
char ch = s.charAt(i);
Character c = new Character(ch);
String token = (String) codeMap.get(c);
if(token == null) {
if(ch < 128) {
buff.append(ch);
} else {
buff.append('&');
buff.append('#');
buff.append((int)ch);
buff.append(';');
}
} else {
buff.append('&');
buff.append(token);
buff.append(';');
}
}
return buff.toString();
}
public static String convertHtmlToString(String html) {
if(html == null) { if(html == null) {
return null; return null;
} }
...@@ -111,5 +144,4 @@ public class HtmlConverter { ...@@ -111,5 +144,4 @@ public class HtmlConverter {
return buff.toString(); return buff.toString();
} }
} }
...@@ -31,7 +31,7 @@ public class Indexer { ...@@ -31,7 +31,7 @@ public class Indexer {
boolean title; boolean title;
boolean heading; boolean heading;
private static final int MIN_WORDSIZE = 3; private static final int MIN_WORD_SIZE = 3;
private static final int MAX_RELATIONS = 20; private static final int MAX_RELATIONS = 20;
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
...@@ -222,7 +222,7 @@ public class Indexer { ...@@ -222,7 +222,7 @@ public class Indexer {
// buff.append(weight.value); // buff.append(weight.value);
} }
} }
// TODO optimization: could support "a name=" and go to _first_ occurance, or scan page and mark // TODO optimization: could support "a name=" and go to _first_ occurrence, or scan page and mark
output.println("ref['"+convertUTF(first)+"']='"+buff.toString()+"';"); output.println("ref['"+convertUTF(first)+"']='"+buff.toString()+"';");
output.println("// totalRelations: "+totalRelations); output.println("// totalRelations: "+totalRelations);
} }
...@@ -290,7 +290,7 @@ public class Indexer { ...@@ -290,7 +290,7 @@ public class Indexer {
} }
void process(String text) { void process(String text) {
text = HtmlConverter.convertHtml(text); text = HtmlConverter.convertHtmlToString(text);
if(title) { if(title) {
if(page.title == null) { if(page.title == null) {
page.title = text; page.title = text;
...@@ -312,7 +312,7 @@ public class Indexer { ...@@ -312,7 +312,7 @@ public class Indexer {
false); false);
while (t.hasMoreTokens()) { while (t.hasMoreTokens()) {
String token = t.nextToken(); String token = t.nextToken();
if(token.length()<MIN_WORDSIZE) { if(token.length()<MIN_WORD_SIZE) {
continue; continue;
} }
if(Character.isDigit(token.charAt(0))) { if(Character.isDigit(token.charAt(0))) {
......
...@@ -47,7 +47,7 @@ class H2Adapter extends DatabaseAdapter ...@@ -47,7 +47,7 @@ class H2Adapter extends DatabaseAdapter
private String schemaName; private String schemaName;
/** /**
* Constructs a H2 adapter based on the given JDBCmetadata. * Constructs a H2 adapter based on the given JDBC metadata.
* @param dictionary The Dictionary to use * @param dictionary The Dictionary to use
* @param metadata the database metadata. * @param metadata the database metadata.
*/ */
...@@ -75,7 +75,7 @@ class H2Adapter extends DatabaseAdapter ...@@ -75,7 +75,7 @@ class H2Adapter extends DatabaseAdapter
} }
/** /**
* Accessor for the vendor ID for this adapter. * Getter for the vendor ID for this adapter.
* @return The vendor ID * @return The vendor ID
*/ */
public String getVendorID() public String getVendorID()
...@@ -85,7 +85,7 @@ class H2Adapter extends DatabaseAdapter ...@@ -85,7 +85,7 @@ class H2Adapter extends DatabaseAdapter
/** /**
* Accessor for a Connection to the datastore. * Accessor for a Connection to the datastore.
* @param ds The data source. Possible to have more than one datasource for failover * @param ds The data source. Possible to have more than one data source for fail over
* @param userName The username for the datastore * @param userName The username for the datastore
* @param password The password for the datastore * @param password The password for the datastore
* @param isolationLevel The level of transaction isolation * @param isolationLevel The level of transaction isolation
...@@ -149,7 +149,7 @@ class H2Adapter extends DatabaseAdapter ...@@ -149,7 +149,7 @@ class H2Adapter extends DatabaseAdapter
/** /**
* Method to return the SQL to append to the SELECT clause of a SELECT statement to handle * Method to return the SQL to append to the SELECT clause of a SELECT statement to handle
* restriction of ranges using the LIMUT keyword. * restriction of ranges using the LIMIT keyword.
* @param offset The offset to return from * @param offset The offset to return from
* @param count The number of items to return * @param count The number of items to return
* @return The SQL to append to allow for ranges using LIMIT. * @return The SQL to append to allow for ranges using LIMIT.
...@@ -244,8 +244,8 @@ class H2Adapter extends DatabaseAdapter ...@@ -244,8 +244,8 @@ class H2Adapter extends DatabaseAdapter
} }
/** /**
* Whether we support autoincrementing fields. * Whether we support auto incrementing fields.
* @return whether we support autoincrementing fields. * @return whether we support auto incrementing fields.
**/ **/
public boolean supportsAutoIncrementFields() public boolean supportsAutoIncrementFields()
{ {
...@@ -264,7 +264,7 @@ class H2Adapter extends DatabaseAdapter ...@@ -264,7 +264,7 @@ class H2Adapter extends DatabaseAdapter
} }
/** /**
* Accessor for the auto-increment keyword for generating DDLs (CREATE TABLEs...). * Accessor for the auto-increment keyword for generating DDLs (CREATE TABLE...).
* @return The keyword for a column using auto-increment * @return The keyword for a column using auto-increment
**/ **/
public String getAutoIncrementKeyword() public String getAutoIncrementKeyword()
...@@ -273,7 +273,7 @@ class H2Adapter extends DatabaseAdapter ...@@ -273,7 +273,7 @@ class H2Adapter extends DatabaseAdapter
} }
/** /**
* Method to retutn the INSERT statement to use when inserting into a table that has no * Method to return the INSERT statement to use when inserting into a table that has no
* columns specified. This is the case when we have a single column in the table and that column * columns specified. This is the case when we have a single column in the table and that column
* is autoincrement/identity (and so is assigned automatically in the datastore). * is autoincrement/identity (and so is assigned automatically in the datastore).
* @param table The table * @param table The table
...@@ -298,7 +298,7 @@ class H2Adapter extends DatabaseAdapter ...@@ -298,7 +298,7 @@ class H2Adapter extends DatabaseAdapter
* Whether this datastore supports the use of CHECK after the column * Whether this datastore supports the use of CHECK after the column
* definitions in CREATE TABLE statements (DDL). * definitions in CREATE TABLE statements (DDL).
* e.g. * e.g.
* CREATE TABLE XXX * CREATE TABLE XYZ
* ( * (
* COL_A int, * COL_A int,
* COL_B char(1), * COL_B char(1),
......
...@@ -28,8 +28,8 @@ public class H2Dialect extends Dialect { ...@@ -28,8 +28,8 @@ public class H2Dialect extends Dialect {
try { try {
Class constants = ReflectHelper.classForName( "org.h2.engine.Constants" ); Class constants = ReflectHelper.classForName( "org.h2.engine.Constants" );
Integer build = (Integer)constants.getDeclaredField("BUILD_ID" ).get(null); Integer build = (Integer)constants.getDeclaredField("BUILD_ID" ).get(null);
int buildid = build.intValue(); int buildId = build.intValue();
if(buildid < 32) { if(buildId < 32) {
querySequenceString = "select name from information_schema.sequences"; querySequenceString = "select name from information_schema.sequences";
} }
} catch(Throwable e) { } catch(Throwable e) {
...@@ -141,7 +141,7 @@ public class H2Dialect extends Dialect { ...@@ -141,7 +141,7 @@ public class H2Dialect extends Dialect {
// registerFunction("minute", new StandardSQLFunction("minute", Hibernate.INTEGER)); // registerFunction("minute", new StandardSQLFunction("minute", Hibernate.INTEGER));
// registerFunction("month", new StandardSQLFunction("month", Hibernate.INTEGER)); // registerFunction("month", new StandardSQLFunction("month", Hibernate.INTEGER));
registerFunction("monthname", new StandardSQLFunction("monthname", Hibernate.STRING)); registerFunction("monthname", new StandardSQLFunction("monthname", Hibernate.STRING));
registerFunction("quater", new StandardSQLFunction("quater", Hibernate.INTEGER)); registerFunction("quarter", new StandardSQLFunction("quarter", Hibernate.INTEGER));
// registerFunction("second", new StandardSQLFunction("second", Hibernate.INTEGER)); // registerFunction("second", new StandardSQLFunction("second", Hibernate.INTEGER));
registerFunction("week", new StandardSQLFunction("week", Hibernate.INTEGER)); registerFunction("week", new StandardSQLFunction("week", Hibernate.INTEGER));
// registerFunction("year", new StandardSQLFunction("year", Hibernate.INTEGER)); // registerFunction("year", new StandardSQLFunction("year", Hibernate.INTEGER));
...@@ -246,15 +246,15 @@ public class H2Dialect extends Dialect { ...@@ -246,15 +246,15 @@ public class H2Dialect extends Dialect {
/** /**
* Extract the name of the violated constraint from the given SQLException. * Extract the name of the violated constraint from the given SQLException.
* *
* @param sqle The exception that was the result of the constraint violation. * @param e The exception that was the result of the constraint violation.
* @return The extracted constraint name. * @return The extracted constraint name.
*/ */
public String extractConstraintName(SQLException sqle) { public String extractConstraintName(SQLException e) {
String constraintName = null; String constraintName = null;
// 23000: Check constraint violation: {0} // 23000: Check constraint violation: {0}
// 23001: Unique index or primary key violation: {0} // 23001: Unique index or primary key violation: {0}
if(sqle.getSQLState().startsWith("23")) { if(e.getSQLState().startsWith("23")) {
String message = sqle.getMessage(); String message = e.getMessage();
int idx = message.indexOf("violation: "); int idx = message.indexOf("violation: ");
if(idx > 0) { if(idx > 0) {
constraintName = message.substring(idx + "violation: ".length()); constraintName = message.substring(idx + "violation: ".length());
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论