提交 238a2f58 authored 作者: Thomas Mueller's avatar Thomas Mueller

--no commit message

--no commit message
上级 16198b6d
......@@ -122,7 +122,7 @@
<fileset dir="src/main"/>
</copy>
<java classname="org.h2.test.coverage.Coverage" classpath="bin" dir="bin" fork="true">
<arg line="-e org/h2/web -e org/h2/jdbcx -e org/h2/bnf -r org/h2"/>
<arg line="-e org/h2/server/web -e org/h2/server/ftp -e org/h2/server/pg -e org/h2/fulltext -e org/h2/tools/Console -e org/h2/tools/Recover -e org/h2/util/StartBrowser -e org/h2/tools/ConvertTraceFile -e org/h2/util/Resources -e org/h2/jdbcx -e org/h2/bnf -r org/h2"/>
</java>
<javac target="${jdk}" source="${jdk}" executable="${javac}" srcdir="bin" destdir="bin" debug="true" includes="org/h2/**"/>
</target>
......
......@@ -235,6 +235,7 @@ For a list of applications that work with or use H2, see:
<a href="http://groups.google.com/group/h2-database/web/h2-in-use">
http://groups.google.com/group/h2-database/web/h2-in-use
</a>
</p>
<br /><a name="connection_modes"></a>
<h2>Connection Modes</h2>
......
......@@ -36,19 +36,21 @@ Hypersonic SQL or HSQLDB. H2 is built from scratch.
<br /><a name="changelog"></a>
<h2>Change Log</h2>
<p>
The up-to-date change log is available here:
<a href="http://groups.google.com/group/h2-database/web/change-log">
http://groups.google.com/group/h2-database/web/change-log
</a>
</p>
<br /><a name="roadmap"></a>
<h2>Roadmap</h2>
<p>
The current roadmap is available here:
<a href="http://groups.google.com/group/h2-database/web/roadmap">
http://groups.google.com/group/h2-database/web/roadmap
</a>
</p>
<h3>Not Planned</h3>
<ul>
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -7,7 +7,7 @@ package org.h2.engine;
import java.lang.ref.WeakReference;
/**
* This class is reponsible to close a database if the application did not close a connection.
* This class is responsible to close a database if the application did not close a connection.
*/
public class DatabaseCloser extends Thread {
......
......@@ -206,11 +206,11 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
public String getColumnListSQL() {
StringBuffer buff = new StringBuffer();
for (int i = 0; i < columns.length; i++) {
for (int i = 0; i < indexColumns.length; i++) {
if (i > 0) {
buff.append(", ");
}
buff.append(columns[i].getSQL());
buff.append(indexColumns[i].getSQL());
}
return buff.toString();
}
......
......@@ -258,7 +258,7 @@ public class MultiVersionIndex implements Index {
}
void debug(String s, Session session, SearchRow row) throws SQLException {
// System.out.println(this + " " + s + " sess:" + (session == null ? -1: session.getId()) + " " + (row == null ? "" : row.getValue(0).getString()));
// System.out.println(this + " " + s + " session:" + (session == null ? -1: session.getId()) + " " + (row == null ? "" : row.getValue(0).getString()));
}
}
......@@ -252,6 +252,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
* </li><li>11 CARDINALITY (int) numbers of unique values
* </li><li>12 PAGES (int) number of pages use (always 0)
* </li><li>13 FILTER_CONDITION (String) filter condition (always empty)
* </li><li>14 SORT_TYPE (int) the sort type bit map: 1=DESCENDING, 2=NULLS_FIRST, 4=NULLS_LAST
* </li></ul>
*
* @param catalog null (to get all objects) or the catalog name
......@@ -289,7 +290,8 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
+ "ASC_OR_DESC, "
+ "CARDINALITY, " // TODO meta data for number of unique values in an index
+ "PAGES, "
+ "FILTER_CONDITION "
+ "FILTER_CONDITION, "
+ "SORT_TYPE "
+ "FROM INFORMATION_SCHEMA.INDEXES "
+ "WHERE TABLE_CATALOG LIKE ? "
+ "AND TABLE_SCHEMA LIKE ? "
......
......@@ -4,55 +4,44 @@
*/
package org.h2.security;
import java.io.IOException;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.sql.SQLException;
//#ifdef JDK14
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.security.Key;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.security.KeyFactory;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.security.UnrecoverableKeyException;
import java.security.cert.Certificate;
import java.security.cert.CertificateEncodingException;
import java.security.cert.CertificateFactory;
import java.security.spec.PKCS8EncodedKeySpec;
import java.util.Enumeration;
import java.sql.SQLException;
import java.util.Properties;
import javax.net.ServerSocketFactory;
import javax.net.ssl.SSLServerSocket;
import javax.net.ssl.SSLServerSocketFactory;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
import org.h2.message.Message;
import org.h2.util.ByteUtils;
import org.h2.util.FileUtils;
import org.h2.util.IOUtils;
//#endif
/**
*
* keytool -genkey -alias h2 -keyalg RSA -dname "cn=H2" -validity 25000 -keypass h2pass -keystore h2.keystore -storepass h2pass
*
*
*
* @author Thomas
* A factory to create encrypted sockets. To generate new keystore, use the
* SecureKeyStoreBuilder tool.
*/
public class SecureSocketFactory {
private static final String KEYSTORE = ".h2.keystore";
private static final String KEYSTORE_KEY = "javax.net.ssl.keyStore";
private static final String KEYSTORE_PASSWORD_KEY = "javax.net.ssl.keyStorePassword";
private static final String KEYSTORE_PASSWORD = "h2pass";
public static final String KEYSTORE_PASSWORD = "h2pass";
// TODO security / SSL: need a way to disable anonymous ssl
private static final boolean ENABLE_ANONYMOUS_SSL = true;
......@@ -107,7 +96,7 @@ public class SecureSocketFactory {
return ByteUtils.convertStringToBytes(hex);
}
private byte[] getKeyStoreBytes(KeyStore store, String password) throws SQLException {
private static byte[] getKeyStoreBytes(KeyStore store, String password) throws SQLException {
try {
ByteArrayOutputStream bout = new ByteArrayOutputStream();
store.store(bout, KEYSTORE_PASSWORD.toCharArray());
......@@ -117,16 +106,7 @@ public class SecureSocketFactory {
}
}
public static void main(String[] a) throws Exception {
// first, create a keystore using:
// keytool -genkey -alias h2 -keyalg RSA -dname "cn=H2" -validity 25000 -keypass h2pass -keystore h2.keystore -storepass h2pass
// then run this application to generate the source code
// then replace the code in the function getKeyStore as specified
KeyStore store = getKeyStore(KEYSTORE_PASSWORD);
printKeystore(store, KEYSTORE_PASSWORD);
}
private static KeyStore getKeyStore(String password) throws SQLException {
public static KeyStore getKeyStore(String password) throws SQLException {
try {
// The following source code can be re-generated when you have a keystore file.
// This code is (hopefully) more Java version independent than using keystores directly.
......@@ -154,38 +134,6 @@ public class SecureSocketFactory {
}
}
private static void printKeystore(KeyStore store, String password) throws KeyStoreException, NoSuchAlgorithmException, UnrecoverableKeyException, CertificateEncodingException {
System.out.println("KeyStore store = KeyStore.getInstance(\""+store.getType()+"\");");
System.out.println("store.load(null, password.toCharArray());");
//System.out.println("keystore provider="+store.getProvider().getName());
Enumeration en = store.aliases();
while (en.hasMoreElements()) {
String alias = (String) en.nextElement();
Key key = store.getKey(alias, password.toCharArray());
System.out.println("KeyFactory keyFactory = KeyFactory.getInstance(\"" + key.getAlgorithm() + "\");");
System.out.println("store.load(null, password.toCharArray());");
String pkFormat = key.getFormat();
String encoded = ByteUtils.convertBytesToString(key.getEncoded());
System.out.println(pkFormat + "EncodedKeySpec keySpec = new " + pkFormat + "EncodedKeySpec(getBytes(\""
+ encoded + "\"));");
System.out.println("PrivateKey privateKey = keyFactory.generatePrivate(keySpec);");
System.out.println("Certificate[] certs = new Certificate[]{");
Certificate[] certs = store.getCertificateChain(alias);
for (int i = 0; i < certs.length; i++) {
Certificate cert = certs[i];
System.out.println(" CertificateFactory.getInstance(\""+cert.getType()+"\").");
String enc = ByteUtils.convertBytesToString(cert.getEncoded());
System.out.println(" generateCertificate(new ByteArrayInputStream(getBytes(\""+enc+"\"))),");
// PublicKey pubKey = cert.getPublicKey();
// System.out.println(" publicKey algorithm="+pubKey.getAlgorithm());
// System.out.println(" publicKey format="+pubKey.getFormat());
// System.out.println(" publicKey format="+ByteUtils.convertBytesToString(pubKey.getEncoded()));
}
System.out.println("};");
System.out.println("store.setKeyEntry(\""+alias+"\", privateKey, password.toCharArray(), certs);");
}
}
private void setKeystore() throws IOException, SQLException {
Properties p = System.getProperties();
if (p.getProperty(KEYSTORE_KEY) == null) {
......@@ -220,16 +168,6 @@ public class SecureSocketFactory {
return newList;
}
// private void listCipherSuites(SSLServerSocketFactory f) {
// String[] def = f.getDefaultCipherSuites();
// for(int i=0; i<def.length; i++) {
// System.out.println("default = " + def[i]);
// }
// String[] sup = f.getSupportedCipherSuites();
// for(int i=0; i<sup.length; i++) {
// System.out.println("supported = " + sup[i]);
// }
// }
//#endif
}
......@@ -40,6 +40,7 @@ import org.h2.log.InDoubtTransaction;
import org.h2.message.Message;
import org.h2.result.Row;
import org.h2.result.SearchRow;
import org.h2.result.SortOrder;
import org.h2.schema.Constant;
import org.h2.schema.Schema;
import org.h2.schema.Sequence;
......@@ -143,7 +144,8 @@ public class MetaTable extends Table {
"FILTER_CONDITION",
"REMARKS",
"SQL",
"ID INT"
"ID INT",
"SORT_TYPE INT"
});
indexColumnName = "TABLE_NAME";
break;
......@@ -614,9 +616,10 @@ public class MetaTable extends Table {
if (index.getCreateSQL() == null) {
continue;
}
Column[] cols = index.getColumns();
IndexColumn[] cols = index.getIndexColumns();
for (int k = 0; k < cols.length; k++) {
Column column = cols[k];
IndexColumn idxCol = cols[k];
Column column = idxCol.column;
add(rows, new String[] {
catalog, // TABLE_CATALOG
identifier(table.getSchema().getName()), // TABLE_SCHEMA
......@@ -630,12 +633,13 @@ public class MetaTable extends Table {
index.getIndexType().getSQL(), // INDEX_TYPE_NAME
index.getIndexType().belongsToConstraint() ? "TRUE" : "FALSE", // IS_GENERATED
"" + DatabaseMetaData.tableIndexOther, // INDEX_TYPE
"A", // ASC_OR_DESC
(idxCol.sortType & SortOrder.DESCENDING) != 0 ? "D" : "A", // ASC_OR_DESC
"0", // PAGES
"", // FILTER_CONDITION
replaceNullWithEmpty(index.getComment()), // REMARKS
index.getSQL(), // SQL
"" + index.getId() // ID
"" + index.getId(), // ID
"" + idxCol.sortType, // SORT_TYPE
});
}
}
......
......@@ -15,15 +15,12 @@ import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.HashMap;
import java.util.Iterator;
import org.h2.engine.Constants;
import org.h2.message.Message;
import org.h2.util.ClassUtils;
import org.h2.util.FileUtils;
import org.h2.util.IOUtils;
import org.h2.util.ObjectUtils;
import org.h2.util.JdbcUtils;
import org.h2.util.ScriptReader;
import org.h2.util.StringUtils;
......@@ -36,8 +33,6 @@ import org.h2.util.StringUtils;
*/
public class RunScript {
private static final boolean MULTI_THREAD = false;
private void showUsage() {
System.out.println("java " + getClass().getName() + " -url <url> -user <user> [-password <pwd>] [-script <file>] [-driver <driver] [-options <option> ...]");
}
......@@ -156,19 +151,19 @@ public class RunScript {
return rs;
}
private static void execute(Connection conn, HashMap threadMap, String fileName, boolean continueOnError, String charsetName) throws SQLException, IOException {
private static void execute(Connection conn, String fileName, boolean continueOnError, String charsetName) throws SQLException, IOException {
InputStream in = FileUtils.openFileInputStream(fileName);
String path = FileUtils.getParent(fileName);
try {
in = new BufferedInputStream(in, Constants.IO_BUFFER_SIZE);
InputStreamReader reader = new InputStreamReader(in, charsetName);
execute(conn, threadMap, continueOnError, path, reader, charsetName);
execute(conn, continueOnError, path, reader, charsetName);
} finally {
IOUtils.closeSilently(in);
}
}
private static void execute(Connection conn, HashMap threadMap, boolean continueOnError, String path, Reader reader, String charsetName) throws SQLException, IOException {
private static void execute(Connection conn, boolean continueOnError, String path, Reader reader, String charsetName) throws SQLException, IOException {
Statement stat = conn.createStatement();
ScriptReader r = new ScriptReader(reader);
while (true) {
......@@ -182,24 +177,7 @@ public class RunScript {
if (!FileUtils.isAbsolute(sql)) {
sql = path + File.separator + sql;
}
execute(conn, threadMap, sql, continueOnError, charsetName);
} else if (MULTI_THREAD && sql.startsWith("/*")) {
int idx = sql.indexOf(']');
Integer id = ObjectUtils.getInteger(Integer.parseInt(sql.substring("/*".length(), idx)));
RunScriptThread thread = (RunScriptThread) threadMap.get(id);
if (thread == null) {
Connection c = DriverManager.getConnection(conn.getMetaData().getURL());
thread = new RunScriptThread(id.intValue(), c);
threadMap.put(id, thread);
thread.start();
}
sql = sql.substring(sql.indexOf("*/") + 2).trim();
String up = StringUtils.toUpperEnglish(sql);
thread.addStatement(sql);
if (up.startsWith("CREATE") || up.startsWith("DROP") || up.startsWith("ALTER")) {
thread.executeAll();
} else {
}
execute(conn, sql, continueOnError, charsetName);
} else {
try {
if (sql.trim().length() > 0) {
......@@ -214,15 +192,6 @@ public class RunScript {
}
}
}
Iterator it = threadMap.values().iterator();
while (it.hasNext()) {
RunScriptThread thread = (RunScriptThread) it.next();
try {
thread.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
private static void executeRunscript(String url, String user, String password, String fileName, String options) throws SQLException {
......@@ -258,9 +227,8 @@ public class RunScript {
if (charsetName == null) {
charsetName = Constants.UTF8;
}
HashMap threadMap = new HashMap();
try {
execute(conn, threadMap, fileName, continueOnError, charsetName);
execute(conn, fileName, continueOnError, charsetName);
} finally {
conn.close();
}
......
/*
* Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.tools;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.LinkedList;
import org.h2.constant.ErrorCode;
class RunScriptThread extends Thread {
private int id;
private volatile boolean stop;
private Connection conn;
private LinkedList queue = new LinkedList();
RunScriptThread(int id, Connection conn) {
this.id = id;
this.conn = conn;
}
void stopThread() {
this.stop = true;
}
void addStatement(String sql) {
synchronized (queue) {
queue.add(sql);
queue.notifyAll();
}
}
void executeAll() {
while (true) {
synchronized (queue) {
if (queue.size() == 0) {
return;
}
try {
queue.wait();
} catch (InterruptedException e) {
// ignore
}
}
}
}
public void run() {
while (!stop) {
String sql;
synchronized (queue) {
while (queue.size() == 0) {
try {
queue.wait();
} catch (InterruptedException e) {
// ignore
}
}
sql = (String) queue.removeFirst();
queue.notifyAll();
}
if (sql == null) {
continue;
}
try {
conn.createStatement().execute("/*" + id + "*/" + sql);
} catch (SQLException e) {
switch (e.getErrorCode()) {
case ErrorCode.LOCK_TIMEOUT_1:
case ErrorCode.TABLE_OR_VIEW_ALREADY_EXISTS_1:
break;
default:
e.printStackTrace();
}
}
}
}
}
......@@ -24,30 +24,6 @@ public class IntArray {
this.data = data;
size = data.length;
}
public static int[] clone(int[] array) {
if (array == null) {
return null;
}
int[] copy = new int[array.length];
System.arraycopy(array, 0, copy, 0, array.length);
return copy;
}
public static boolean equals(int[] a, int[] b) {
if (a == null || b == null) {
return a == b;
}
if (a.length != b.length) {
return false;
}
for (int i = 0; i < a.length; i++) {
if (a[i] != b[i]) {
return false;
}
}
return true;
}
public void add(int value) {
checkCapacity();
......
......@@ -28,11 +28,6 @@ public class ObjectArray {
data = new Object[size > 1 ? size : 1];
}
public ObjectArray(Object[] data) {
this.data = data;
size = data.length;
}
public ObjectArray(Collection collection) {
// TODO lib: Collection should not be required
size = collection.size();
......
......@@ -146,9 +146,6 @@ java org.h2.test.TestAll timer
A file is sent although the Japanese translation has not been completed yet.
----
reverse index
Code coverage
At startup, when corrupted, say if LOG=0 was used before
add more MVCC tests
......
......@@ -148,7 +148,7 @@ public class TestCases extends TestBase {
}
private void testDisconnect() throws Exception {
if (config.networked) {
if (config.networked || config.codeCoverage) {
return;
}
deleteDb("cases");
......
......@@ -10,6 +10,7 @@ import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Random;
import org.h2.result.SortOrder;
import org.h2.test.TestBase;
public class TestIndex extends TestBase {
......@@ -28,6 +29,8 @@ public class TestIndex extends TestBase {
}
public void test() throws Exception {
testDescIndex();
if (config.networked && config.big) {
return;
}
......@@ -67,6 +70,33 @@ public class TestIndex extends TestBase {
conn.close();
}
void testDescIndex() throws Exception {
if (config.memory) {
return;
}
ResultSet rs;
reconnect();
stat.execute("CREATE TABLE TEST(ID INT)");
stat.execute("CREATE INDEX IDX_ND ON TEST(ID DESC)");
rs = conn.getMetaData().getIndexInfo(null, null, "TEST", false, false);
rs.next();
check(rs.getString("ASC_OR_DESC"), "D");
check(rs.getInt("SORT_TYPE"), SortOrder.DESCENDING);
stat.execute("INSERT INTO TEST SELECT X FROM SYSTEM_RANGE(1, 30)");
rs = stat.executeQuery("SELECT COUNT(*) FROM TEST WHERE ID BETWEEN 10 AND 20");
rs.next();
check(rs.getInt(1), 11);
reconnect();
rs = conn.getMetaData().getIndexInfo(null, null, "TEST", false, false);
rs.next();
check(rs.getString("ASC_OR_DESC"), "D");
check(rs.getInt("SORT_TYPE"), SortOrder.DESCENDING);
rs = stat.executeQuery("SELECT COUNT(*) FROM TEST WHERE ID BETWEEN 10 AND 20");
rs.next();
check(rs.getInt(1), 11);
stat.execute("DROP TABLE TEST");
}
String getRandomString(int len) {
StringBuffer buff = new StringBuffer();
......
......@@ -235,7 +235,7 @@ public class TestLob extends TestBase {
Statement stat = conn.createStatement();
stat.execute("create table test(id int, data clob)");
stat.execute("insert into test values(1, space(1000));");
stat.execute("insert into test values(2, space(1000));");
stat.execute("insert into test values(2, space(10000));");
stat.execute("create table test2(id int, data clob);");
stat.execute("insert into test2 select * from test;");
stat.execute("drop table test;");
......
......@@ -24,20 +24,20 @@ public class TestSequence extends TestBase {
deleteDb("sequence");
Connection conn = getConnection("sequence");
Statement stat = conn.createStatement();
stat.execute("create sequence testSequence");
stat.execute("create sequence testSequence3 cache 3");
stat.execute("create sequence test_Sequence");
stat.execute("create sequence test_Sequence3 cache 3");
conn.close();
conn = getConnection("sequence");
stat = conn.createStatement();
stat.execute("call next value for testSequence");
stat.execute("call next value for testSequence3");
stat.execute("call next value for test_Sequence");
stat.execute("call next value for test_Sequence3");
ResultSet rs = stat.executeQuery("select * from information_schema.sequences");
rs.next();
check(rs.getString("SEQUENCE_NAME"), "TESTSEQUENCE3");
check(rs.getString("CACHE"), "3");
rs.next();
check(rs.getString("SEQUENCE_NAME"), "TESTSEQUENCE");
check(rs.getString("SEQUENCE_NAME"), "TEST_SEQUENCE");
check(rs.getString("CACHE"), "32");
rs.next();
check(rs.getString("SEQUENCE_NAME"), "TEST_SEQUENCE3");
check(rs.getString("CACHE"), "3");
checkFalse(rs.next());
conn.close();
}
......
......@@ -569,11 +569,11 @@ public class TestMetaData extends TestBase {
stat.executeUpdate("CREATE INDEX IDX_TEXT_DEC ON TEST(TEXT_V,DEC_V)");
stat.executeUpdate("CREATE UNIQUE INDEX IDX_DATE ON TEST(DATE_V)");
rs = meta.getIndexInfo(null, null, "TEST", false, false);
testResultSetMeta(rs, 13, new String[] { "TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "NON_UNIQUE",
testResultSetMeta(rs, 14, new String[] { "TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "NON_UNIQUE",
"INDEX_QUALIFIER", "INDEX_NAME", "TYPE", "ORDINAL_POSITION", "COLUMN_NAME", "ASC_OR_DESC",
"CARDINALITY", "PAGES", "FILTER_CONDITION" }, new int[] { Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,
"CARDINALITY", "PAGES", "FILTER_CONDITION", "SORT_TYPE"}, new int[] { Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,
DataType.TYPE_BOOLEAN, Types.VARCHAR, Types.VARCHAR, Types.SMALLINT, Types.SMALLINT, Types.VARCHAR,
Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.VARCHAR }, null, null);
Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.VARCHAR, Types.INTEGER}, null, null);
testResultSetOrdered(rs, new String[][] {
{ catalog, Constants.SCHEMA_MAIN, "TEST", "FALSE", catalog, "IDX_DATE",
"" + DatabaseMetaData.tableIndexOther, "1", "DATE_V", "A", "0", "0", "" },
......@@ -586,11 +586,11 @@ public class TestMetaData extends TestBase {
stat.executeUpdate("DROP INDEX IDX_TEXT_DEC");
stat.executeUpdate("DROP INDEX IDX_DATE");
rs = meta.getIndexInfo(null, null, "TEST", false, false);
testResultSetMeta(rs, 13, new String[] { "TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "NON_UNIQUE",
testResultSetMeta(rs, 14, new String[] { "TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "NON_UNIQUE",
"INDEX_QUALIFIER", "INDEX_NAME", "TYPE", "ORDINAL_POSITION", "COLUMN_NAME", "ASC_OR_DESC",
"CARDINALITY", "PAGES", "FILTER_CONDITION" }, new int[] { Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,
"CARDINALITY", "PAGES", "FILTER_CONDITION", "SORT_TYPE" }, new int[] { Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,
DataType.TYPE_BOOLEAN, Types.VARCHAR, Types.VARCHAR, Types.SMALLINT, Types.SMALLINT, Types.VARCHAR,
Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.VARCHAR }, null, null);
Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.VARCHAR, Types.INTEGER }, null, null);
testResultSetOrdered(rs, new String[][] { { catalog, Constants.SCHEMA_MAIN, "TEST", "FALSE", catalog,
"PRIMARY_KEY_1", "" + DatabaseMetaData.tableIndexOther, "1", "ID", "A", "0", "0", "" } });
trace("getPrimaryKeys");
......
CREATE TABLE TEST(ID INT);
INSERT INTO TEST VALUES(1), (2), (3);
create index idxdesc on test(id desc);
create index idx_desc on test(id desc);
select * from test where id between 0 and 1;
> 1;
select * from test where id between 3 and 4;
......
/*
* Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.security;
import java.security.Key;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.UnrecoverableKeyException;
import java.security.cert.Certificate;
import java.security.cert.CertificateEncodingException;
import java.util.Enumeration;
import org.h2.util.ByteUtils;
/**
* Tool to generate source code for the SecureSocketFactory.
* First, create a keystore using:
* <pre>
* keytool -genkey -alias h2 -keyalg RSA -dname "cn=H2" -validity 25000 -keypass h2pass -keystore h2.keystore -storepass h2pass
* </pre>
* Then run this application to generate the source code.
* Then replace the code in the function SecureSocketFactory.getKeyStore as specified
*/
public class SecureKeyStoreBuilder {
public static void main(String[] a) throws Exception {
String password = SecureSocketFactory.KEYSTORE_PASSWORD;
KeyStore store = SecureSocketFactory.getKeyStore(password);
printKeystore(store, password);
}
private static void printKeystore(KeyStore store, String password) throws KeyStoreException, NoSuchAlgorithmException, UnrecoverableKeyException, CertificateEncodingException {
System.out.println("KeyStore store = KeyStore.getInstance(\""+store.getType()+"\");");
System.out.println("store.load(null, password.toCharArray());");
//System.out.println("keystore provider="+store.getProvider().getName());
Enumeration en = store.aliases();
while (en.hasMoreElements()) {
String alias = (String) en.nextElement();
Key key = store.getKey(alias, password.toCharArray());
System.out.println("KeyFactory keyFactory = KeyFactory.getInstance(\"" + key.getAlgorithm() + "\");");
System.out.println("store.load(null, password.toCharArray());");
String pkFormat = key.getFormat();
String encoded = ByteUtils.convertBytesToString(key.getEncoded());
System.out.println(pkFormat + "EncodedKeySpec keySpec = new " + pkFormat + "EncodedKeySpec(getBytes(\""
+ encoded + "\"));");
System.out.println("PrivateKey privateKey = keyFactory.generatePrivate(keySpec);");
System.out.println("Certificate[] certs = new Certificate[]{");
Certificate[] certs = store.getCertificateChain(alias);
for (int i = 0; i < certs.length; i++) {
Certificate cert = certs[i];
System.out.println(" CertificateFactory.getInstance(\""+cert.getType()+"\").");
String enc = ByteUtils.convertBytesToString(cert.getEncoded());
System.out.println(" generateCertificate(new ByteArrayInputStream(getBytes(\""+enc+"\"))),");
// PublicKey pubKey = cert.getPublicKey();
// System.out.println(" publicKey algorithm="+pubKey.getAlgorithm());
// System.out.println(" publicKey format="+pubKey.getFormat());
// System.out.println(" publicKey format="+ByteUtils.convertBytesToString(pubKey.getEncoded()));
}
System.out.println("};");
System.out.println("store.setKeyEntry(\""+alias+"\", privateKey, password.toCharArray(), certs);");
}
}
// private void listCipherSuites(SSLServerSocketFactory f) {
// String[] def = f.getDefaultCipherSuites();
// for (int i = 0; i < def.length; i++) {
// System.out.println("default = " + def[i]);
// }
// String[] sup = f.getSupportedCipherSuites();
// for (int i = 0; i < sup.length; i++) {
// System.out.println("supported = " + sup[i]);
// }
// }
}
......@@ -511,4 +511,5 @@ lumber thus taking repositories ago delegated mention leaks pgsql seeded felt ef
spfile svr pkey synced semicolon terminating
framework constructing architectural jmatter workgroup upgraded naked stopper skipping assumed
opensource atlassian hhh establish pawel nice italiano ucchino paolo italian pier shorter although
uklinux credential crypt kerberos redferni routine
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论