提交 61f89401 authored 作者: Thomas Mueller's avatar Thomas Mueller

--no commit message

--no commit message
上级 67a90bac
......@@ -40,7 +40,11 @@ Hypersonic SQL or HSQLDB. H2 is built from scratch.
<h3>Version 1.0 (Current)</h3>
<h3>Version 1.0.60 (2007-10-?)</h3><ul>
<li>CSV: New methods to set the escape character and field delimiter in the Csv tool and the CSVWRITE and CSVREAD methods.
<li>Stack traces did not include the SQL statement in all cases where they could have.
Also, stack traces with SQL statement are now shorter.
</li><li>Linked tables: now tables in non-default schemas are supported as well
</li><li>New Italian translation from PierPaolo Ucchino. Thanks a lot!
</li><li>CSV: New methods to set the escape character and field delimiter in the Csv tool and the CSVWRITE and CSVREAD methods.
</li><li>Prepared statements could not be used after data definition statements (creating tables and so on). Fixed.
</li><li>PreparedStatement.setMaxRows could not be changed to a higher value after the statement was executed.
</li><li>The H2 Console could not connect twice to the same H2 embedded database at the same time. Fixed.
......@@ -554,6 +558,7 @@ Hypersonic SQL or HSQLDB. H2 is built from scratch.
</li><li>Eclipse plugin
</li><li>iReport to support H2
</li><li>Implement missing JDBC API (CallableStatement,...)
</li><li>Sequence: add features [NO] MINVALUE, MAXVALUE, CACHE, CYCLE
</li><li>Compression of the cache
</li><li>Run H2 Console inside servlet (pass-through servlet of fix the JSP / app)
</li><li>Include SMPT (mail) server (at least client) (alert on cluster failure, low disk space,...)
......@@ -745,7 +750,6 @@ Hypersonic SQL or HSQLDB. H2 is built from scratch.
</li><li>Implement a SQLData interface to map your data over to a custom object
</li><li>Extend H2 Console to run tools (show command line as well)
</li><li>Make DDL (Data Definition) operations transactional
</li><li>Sequence: add features [NO] MINVALUE, MAXVALUE, CACHE, CYCLE
</li><li>Allow execution time prepare for SELECT * FROM CSVREAD(?, 'columnNameString')
</li><li>Support multiple directories (on different hard drives) for the same database
</li><li>Server protocol: use challenge response authentication, but client sends hash(user+password) encrypted with response
......
......@@ -12,7 +12,6 @@ import java.util.EventListener;
* A database event listener can be registered when connecting to a database.
* Example database URL: jdbc:h2:test;DATABASE_EVENT_LISTENER='com.acme.DbListener' *
*/
public interface DatabaseEventListener extends EventListener {
int STATE_SCAN_FILE = 0, STATE_CREATE_INDEX = 1, STATE_RECOVER = 2, STATE_BACKUP_FILE = 3;
......
......@@ -851,7 +851,7 @@ public class Parser {
} else if (currentTokenType == IDENTIFIER) {
// left and right are not keywords (because they are functions as
// well)
if (!isToken("LEFT") && !isToken("RIGHT")) {
if (!isToken("LEFT") && !isToken("RIGHT") && !isToken("FULL")) {
alias = readAliasIdentifier();
}
}
......@@ -1070,6 +1070,8 @@ public class Parser {
}
top.addJoin(join, true, on);
last = join;
} else if (readIf("FULL")) {
throw this.getSyntaxError();
} else if (readIf("INNER")) {
read("JOIN");
TableFilter join = readTableFilter(fromOuter);
......
......@@ -1287,7 +1287,7 @@ public class Database implements DataHandler {
long sizeAvailable = 0;
if (emergencyReserve != null) {
sizeAvailable = emergencyReserve.length();
long newLength = sizeAvailable / 2;
long newLength = sizeAvailable / 4;
if (newLength < SysProperties.EMERGENCY_SPACE_MIN) {
newLength = 0;
noDiskSpace = true;
......
......@@ -26,12 +26,12 @@ import org.h2.value.ValueNull;
public class LinkedIndex extends BaseIndex {
private TableLink link;
private String originalTable;
private String targetTableName;
public LinkedIndex(TableLink table, int id, Column[] columns, IndexType indexType) {
super(table, id, null, columns, indexType);
link = table;
originalTable = link.getOriginalTable();
targetTableName = link.getQualifiedTable();
}
public String getCreateSQL() {
......@@ -47,7 +47,7 @@ public class LinkedIndex extends BaseIndex {
public void add(Session session, Row row) throws SQLException {
StringBuffer buff = new StringBuffer("INSERT INTO ");
buff.append(originalTable);
buff.append(targetTableName);
buff.append(" VALUES(");
for (int i = 0, j = 0; i < row.getColumnCount(); i++) {
Value v = row.getValue(i);
......@@ -104,7 +104,7 @@ public class LinkedIndex extends BaseIndex {
if (buff.length() > 0) {
buff.insert(0, " WHERE ");
}
buff.insert(0, "SELECT * FROM " + originalTable + " T");
buff.insert(0, "SELECT * FROM " + targetTableName + " T");
String sql = buff.toString();
try {
PreparedStatement prep = link.getPreparedStatement(sql);
......@@ -169,7 +169,7 @@ public class LinkedIndex extends BaseIndex {
public void remove(Session session, Row row) throws SQLException {
StringBuffer buff = new StringBuffer("DELETE FROM ");
buff.append(originalTable);
buff.append(targetTableName);
buff.append(" WHERE ");
for (int i = 0; i < row.getColumnCount(); i++) {
if (i > 0) {
......@@ -202,7 +202,7 @@ public class LinkedIndex extends BaseIndex {
public void update(Session session, Row oldRow, Row newRow) throws SQLException {
StringBuffer buff = new StringBuffer("UPDATE ");
buff.append(originalTable).append(" SET ");
buff.append(targetTableName).append(" SET ");
for (int i = 0; i < newRow.getColumnCount(); i++) {
if (i > 0) {
buff.append(", ");
......
......@@ -17,9 +17,10 @@ public class JdbcSQLException extends SQLException {
private static final long serialVersionUID = -8200821788226954151L;
private final String originalMessage;
private final String sql;
private final Throwable cause;
private final String trace;
private String message;
private String sql;
/**
* Creates a SQLException a message, sqlstate and cause.
......@@ -29,26 +30,24 @@ public class JdbcSQLException extends SQLException {
* @param cause the exception that was the reason for this exception
*/
public JdbcSQLException(String message, String sql, String state, int errorCode, Throwable cause, String trace) {
super(buildMessage(message, sql, state), state, errorCode);
super(message, state, errorCode);
this.originalMessage = message;
this.sql = sql;
this.cause = cause;
this.trace = trace;
buildMessage();
//#ifdef JDK14
initCause(cause);
//#endif
}
private static String buildMessage(String message, String sql, String state) {
if (message == null) {
message = "";
}
StringBuffer buff = new StringBuffer(message);
if (sql != null) {
buff.append("; SQL statement: ");
buff.append(sql);
}
return message + " [" + state + "-" + Constants.BUILD_ID + "]";
/**
* Get the detail error message.
*
* @return the message
*/
public String getMessage() {
return message;
}
/**
......@@ -133,6 +132,28 @@ public class JdbcSQLException extends SQLException {
return sql;
}
/**
* INTERNAL
*/
public void setSQL(String sql) {
this.sql = sql;
buildMessage();
}
private void buildMessage() {
StringBuffer buff = new StringBuffer(originalMessage);
if (sql != null) {
buff.append("; SQL statement:\n");
buff.append(sql);
}
buff.append(" [");
buff.append(getSQLState());
buff.append('-');
buff.append(Constants.BUILD_ID);
buff.append(']');
message = buff.toString();
}
/**
* Returns the class name, the message, and in the server mode, the stack trace of the server
*
......
......@@ -139,12 +139,10 @@ public class Message {
public static SQLException addSQL(SQLException e, String sql) {
if (e instanceof JdbcSQLException) {
JdbcSQLException j = (JdbcSQLException) e;
if (j.getSQL() != null) {
return j;
if (j.getSQL() == null) {
j.setSQL(sql);
}
return new JdbcSQLException(j.getOriginalMessage(), j.getSQL(),
j.getSQLState(),
j.getErrorCode(), j, null);
return j;
} else {
return new JdbcSQLException(e.getMessage(), sql,
e.getSQLState(),
......
......@@ -11,9 +11,11 @@ import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Properties;
import java.util.Set;
import org.h2.Driver;
import org.h2.engine.Constants;
......@@ -39,7 +41,7 @@ public class TcpServer implements Service {
private boolean ssl;
private boolean stop;
private ServerSocket serverSocket;
private HashSet running = new HashSet();
private Set running = Collections.synchronizedSet(new HashSet());
private String baseDir;
private String url;
private boolean allowOthers;
......
......@@ -14,7 +14,9 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import org.h2.engine.Constants;
import org.h2.server.Service;
......@@ -32,7 +34,7 @@ public class PgServer implements Service {
private boolean stop;
private boolean log;
private ServerSocket serverSocket;
private HashSet running = new HashSet();
private Set running = Collections.synchronizedSet(new HashSet());
private String baseDir;
private String url;
private boolean allowOthers;
......
......@@ -14,11 +14,13 @@ import java.sql.SQLException;
import java.sql.Statement;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Locale;
import java.util.Properties;
import java.util.Set;
import java.util.TimeZone;
import org.h2.api.DatabaseEventListener;
......@@ -54,6 +56,7 @@ public class WebServer implements Service {
{ "in", "Indonesia"},
{ "pt_PT", "Portugu\u00eas (Europeu)"},
{ "pl", "Polski"},
{ "it", "Italiano"},
};
private static final String[] GENERIC = new String[] {
......@@ -78,7 +81,7 @@ public class WebServer implements Service {
private static int ticker;
private int port;
private boolean allowOthers;
private HashSet running = new HashSet();
private Set running = Collections.synchronizedSet(new HashSet());
private boolean ssl;
private HashMap connInfoMap = new HashMap();
......
......@@ -21,7 +21,8 @@ adminLoginCancel=Abbrechen
adminLoginOk=OK
adminLogout=Beenden
adminOthers=Verbindungen von anderen Computern erlauben
adminPort=Web-Server Port
adminPort=Port
adminPortWeb=Web-Server Port
adminRestart=&Auml;nderungen werden nach einem Neustart des Servers aktiv.
adminSave=Speichern
adminSessions=Aktive Verbindungen
......
......@@ -21,7 +21,8 @@ adminLoginCancel=Cancel
adminLoginOk=OK
adminLogout=Logout
adminOthers=Allow connections from other computers
adminPort=Web server port number
adminPort=Port number
adminPortWeb=Web server port number
adminRestart=Changes take effect after restarting the server.
adminSave=Save
adminSessions=Active Sessions
......
......@@ -21,7 +21,8 @@ adminLoginCancel=Cancelar
adminLoginOk=Aceptar
adminLogout=Desconectar
adminOthers=Permitir conexiones desde otros ordenadores
adminPort=Puerto del servidor Web
adminPort=Puerto
adminPortWeb=Puerto del servidor Web
adminRestart=Los cambios tendr&aacute;n efecto al reiniciar el servidor.
adminSave=Guardar
adminSessions=Sesiones activas
......
......@@ -21,7 +21,8 @@ adminLoginCancel=Annuler
adminLoginOk=OK
adminLogout=D&eacute;connexion
adminOthers=Autoriser les connexions d'ordinateurs distants
adminPort=Num&eacute;ro de port du serveur Web
adminPort=Num&eacute;ro de port
adminPortWeb=Num&eacute;ro de port du serveur Web
adminRestart=Modifications effectu&eacute;es apr&egrave; red&eacute;marrage du serveur.
adminSave=Enregistrer
adminSessions=Sessions actives
......
......@@ -21,7 +21,8 @@ adminLoginCancel=M&eacute;gse
adminLoginOk=OK
adminLogout=Kil&eacute;p&eacute;s
adminOthers=M&aacute;s sz&aacute;m&iacute;t&oacute;g&eacute;pekr&\#337;l kezdem&eacute;nyezett kapcsolatok enged&eacute;lyez&eacute;se
adminPort=Webkiszolg&aacute;l&oacute; portsz&aacute;ma
adminPort=Portsz&aacute;ma
adminPortWeb=Webkiszolg&aacute;l&oacute; portsz&aacute;ma
adminRestart=A v&aacute;ltoztat&aacute;sok a kiszolg&aacute;l&oacute; &uacute;jraind&iacute;t&aacute;sa ut&aacute;n l&eacute;pnek &eacute;rv&eacute;nybe
adminSave=Ment&eacute;s
adminSessions=Akt&iacute;v munkamenetek
......
......@@ -21,7 +21,8 @@ adminLoginCancel=Batal
adminLoginOk=OK
adminLogout=Keluar
adminOthers=Ijinkan koneksi dari komputer lain
adminPort=Nomor port web server
adminPort=Nomor port
adminPortWeb=Nomor port web server
adminRestart=Perubahan akan efektif setelah server di-restart.
adminSave=Simpan
adminSessions=Sesi aktif
......
.translator=PierPaolo Ucchino
a.help=Aiuto
a.language=Italiano
a.lynxNotSupported=Spiacente, Lynx non \u00E8 al momento supportato
a.password=Password
a.remoteConnectionsDisabled=Spiacente, le connessioni remote ('webAllowOthers') sono disabilitate su questo server.
a.title=H2 Pannello di controllo
a.user=Nome utente
admin.executing=Esecuzione in corso
admin.ip=IP
admin.lastAccess=Ultimo accesso
admin.lastQuery=Ultima query
admin.url=URL
adminAllow=Client abilitati
adminConnection=Sicurezza della connessione
adminHttp=Usa connessioni HTTP non criptate
adminHttps=Usa connessioni criptate con SSL (HTTPS)
adminLocal=Abilita solo connessioni locali
adminLogin=Accesso amministratore
adminLoginCancel=Annulla
adminLoginOk=OK
adminLogout=Disconnessione
adminOthers=Abilita connessioni da altri computers
adminPort=Numero di porta
adminPortWeb=Numero di porta del server Web
adminRestart=Le modifiche saranno effettive dopo il riavvio del server.
adminSave=Salva
adminSessions=Connessioni attive
adminShutdown=Shutdown
adminTitle=Pannello di controllo preferenze H2
helpAction=Azione
helpAddAnotherRow=Aggiunge un'altra riga
helpAddDrivers=Aggiunta di altri driver per l'accesso al database
helpAddDriversOnlyJava=Solo la versione Java supporta drivers aggiuntivi (questa caratteristica non e' supportata dalla versione Nativa).
helpAddDriversText=I drivers per il database possono essere inseriti aggiungendo la posizione del file Jar del driver stesso alle variabili di ambiente H2DRIVERS o CLASSPATH. Esempio (Windows)\: Per aggiungere alla libreria il drivers per il database C\:\\Programs\\hsqldb\\lib\\hsqldb.jar, basta modificare la variabile di ambiente H2DRIVERS in C\:\\Programs\\hsqldb\\lib\\hsqldb.jar.
helpAddRow=Aggiunge una nuova riga
helpCommandHistory=Mostra l'elenco dei comandi eseguiti
helpCreateTable=Crea una nuova tabella
helpDeleteRow=Rimuove una riga
helpDisconnect=Disconnette dal database
helpDisplayThis=Mostra questa pagina di aiuto
helpDropTable=Cancella la tabella se esiste
helpExecuteCurrent=Esegue il corrente comando SQL
helpIcon=Icona
helpImportantCommands=Comandi importanti
helpOperations=Operazioni
helpQuery=Seleziona tutto dalla tabella
helpSampleSQL=Programma SQL di esempio
helpStatements=Comandi SQL
helpUpdate=Cambia dei dati in una riga
helpWithColumnsIdName=tramite ID e NOME colonne
login.connect=Connetti
login.driverClass=Classe driver
login.driverNotFound=Il driver del database non \u00E8 stato trovato<br />Guardare in Aiuto su come aggiungere dei drivers
login.goAdmin=Preferenze
login.jdbcUrl=JDBC URL
login.language=Lingua
login.login=Accesso
login.remove=Rimuovi
login.save=Salva
login.savedSetting=Configurazioni salvate
login.settingName=Nome configurazione
login.testConnection=Prova la connessione
login.testSuccessful=Connessione riuscita
login.welcome=Pannello di controllo H2
result.1row=1 riga
result.autoCommitOff=Auto inserimento adesso e' disattivo
result.autoCommitOn=Auto inserimento adesso e' attivo
result.maxrowsSet=Il numero massimo di righe e' stato impostato
result.noRows=nessuna riga
result.noRunningStatement=C'e' un comando in corso di esecuzione
result.rows=righe
result.statementWasCancelled=Il comando e' stato annullato
result.updateCount=Aggiorna il risultato
resultEdit.add=Aggiungi
resultEdit.cancel=Annulla
resultEdit.delete=Cancella
resultEdit.edit=Modifica
resultEdit.editResult=Modifica
resultEdit.save=Salva
toolbar.all=Tutto
toolbar.autoCommit=Auto inserimento
toolbar.autoComplete=Auto completamento
toolbar.autoComplete.full=Pieno
toolbar.autoComplete.normal=Normale
toolbar.autoComplete.off=Disattivo
toolbar.cancelStatement=Annulla il seguente comando
toolbar.clear=Annulla
toolbar.commit=Esegui comando
toolbar.disconnect=Disconnetti
toolbar.history=Comandi eseguiti
toolbar.maxRows=Massimo numero righe
toolbar.refresh=Aggiorna
toolbar.rollback=Annulla comando
toolbar.run=Esegui (Ctrl+Invio)
toolbar.sqlStatement=Comando SQL
tree.admin=Amministratore
tree.current=Valore corrente
tree.hashed=Valore hash
tree.increment=Incremento
tree.indexes=Indici
tree.nonUnique=Non unico
tree.sequences=Sequenze
tree.unique=Unico
tree.users=Utenti
......@@ -21,7 +21,8 @@ adminLoginCancel=\u30AD\u30E3\u30F3\u30BB\u30EB
adminLoginOk=OK
adminLogout=\u30ED\u30B0\u30A2\u30A6\u30C8
adminOthers=\u4ED6\u306E\u30B3\u30F3\u30D4\u30E5\u30FC\u30BF\u304B\u3089\u306E\u63A5\u7D9A\u3092\u8A31\u53EF
adminPort=Web\u30B5\u30FC\u30D0\u30DD\u30FC\u30C8\u756A\u53F7
adminPort=\u30B5\u30FC\u30D0\u30DD\u30FC\u30C8\u756A\u53F7
adminPortWeb=Web\u30B5\u30FC\u30D0\u30DD\u30FC\u30C8\u756A\u53F7
adminRestart=\u5909\u66F4\u306F\u30B5\u30FC\u30D0\u306E\u518D\u8D77\u52D5\u5F8C\u306B\u6709\u52B9\u306B\u306A\u308A\u307E\u3059\u3002
adminSave=\u4FDD\u5B58
adminSessions=\u30A2\u30AF\u30C6\u30A3\u30D6\u30BB\u30C3\u30B7\u30E7\u30F3
......
......@@ -21,7 +21,8 @@ adminLoginCancel=Anuluj
adminLoginOk=OK
adminLogout=Wyloguj
adminOthers=Pozwalaj na po&\#322;&\#261;czenia zdalne
adminPort=Numer portu serwera Web
adminPort=Numer portu
adminPortWeb=Numer portu serwera Web
adminRestart=Zmiany b&\#281;d&\#261; widoczne po zrestartowaniu serwera.
adminSave=Zapisz
adminSessions=Aktywne sesje
......
......@@ -21,7 +21,8 @@ adminLoginCancel=Cancelar
adminLoginOk=Confirmar
adminLogout=Sair
adminOthers=Permitir conex&otilde;es a partir de outro computador na rede
adminPort=N&uacute;mero do porto do servidor
adminPort=N&uacute;mero do porto
adminPortWeb=N&uacute;mero do porto do servidor
adminRestart=As altera&ccedil;&otilde;es apenas ser&atilde;o aplicadas ap&oacute;s reiniciar o servidor.
adminSave=Gravar
adminSessions=Sess&otilde;es activas
......
......@@ -21,7 +21,8 @@ adminLoginCancel=\u53D6\u6D88
adminLoginOk=\u786E\u8BA4
adminLogout=\u6CE8\u9500
adminOthers=\u5141\u8BB8\u6765\u81EA\u5176\u4ED6\u8FDC\u7A0B\u8BA1\u7B97\u673A\u7684\u8FDE\u63A5
adminPort=Web server \u7AEF\u53E3\u53F7
adminPort=\u7AEF\u53E3\u53F7
adminPortWeb=Web server \u7AEF\u53E3\u53F7
adminRestart=\u91CD\u542F\u670D\u52A1\u5668\u540E\u4FEE\u6539\u914D\u7F6E\u5C06\u751F\u6548.
adminSave=\u4FDD\u5B58
adminSessions=\u6D3B\u52A8\u7684\u4F1A\u8BDD
......
......@@ -67,10 +67,10 @@ Initial Developer: H2 Group
${text.adminHttps}<br />
</p>
<h3>
Port number
${text.adminPort}
</h3>
<p>
${text.adminPort}: <input type="text" name="port" value="${port}" />
${text.adminPortWeb}: <input type="text" name="port" value="${port}" />
</p>
<hr />
<p>
......
......@@ -34,7 +34,7 @@ import org.h2.value.DataType;
public class TableLink extends Table {
private String driver, url, user, password, originalTable;
private String driver, url, user, password, originalTable, qualifiedTableName;
private Connection conn;
private HashMap prepared = new HashMap();
private final ObjectArray indexes = new ObjectArray();
......@@ -102,12 +102,18 @@ public class TableLink extends Table {
columnList.add(col);
columnMap.put(n, col);
}
// alternative solution
if (columnList.size() == 0) {
if (originalTable.indexOf('.') < 0 && !StringUtils.isNullOrEmpty(schema)) {
qualifiedTableName = schema + "." + originalTable;
} else {
qualifiedTableName = originalTable;
}
// check if the table is accessible
Statement stat = null;
try {
stat = conn.createStatement();
rs = stat.executeQuery("SELECT * FROM " + originalTable + " T WHERE 1=0");
rs = stat.executeQuery("SELECT * FROM " + qualifiedTableName + " T WHERE 1=0");
if (columnList.size() == 0) {
// alternative solution
ResultSetMetaData rsMeta = rs.getMetaData();
for (i = 0; i < rsMeta.getColumnCount();) {
String n = rsMeta.getColumnName(i + 1);
......@@ -123,13 +129,13 @@ public class TableLink extends Table {
columnList.add(col);
columnMap.put(n, col);
}
}
} catch (SQLException e) {
throw Message.getSQLException(ErrorCode.TABLE_OR_VIEW_NOT_FOUND_1, new String[] { originalTable + "("
+ e.toString() + ")" }, e);
} finally {
JdbcUtils.closeSilently(stat);
}
}
Column[] cols = new Column[columnList.size()];
columnList.toArray(cols);
setColumns(cols);
......@@ -262,7 +268,7 @@ public class TableLink extends Table {
}
public long getRowCount(Session session) throws SQLException {
PreparedStatement prep = getPreparedStatement("SELECT COUNT(*) FROM " + originalTable);
PreparedStatement prep = getPreparedStatement("SELECT COUNT(*) FROM " + qualifiedTableName);
ResultSet rs = prep.executeQuery();
rs.next();
long count = rs.getLong(1);
......@@ -270,8 +276,8 @@ public class TableLink extends Table {
return count;
}
public String getOriginalTable() {
return originalTable;
public String getQualifiedTable() {
return qualifiedTableName;
}
public PreparedStatement getPreparedStatement(String sql) throws SQLException {
......
......@@ -146,7 +146,9 @@ java org.h2.test.TestAll timer
/*
web page translation
CREATE USER "Pawel" PASSWORD 'pawel' // can't establish connection
CREATE USER PAWEL PASSWORD 'pawel' // everything OK
At startup, when corrupted, say if LOG=0 was used before
......
......@@ -18,6 +18,7 @@ import org.h2.test.TestBase;
public class TestLinkedTable extends TestBase {
public void test() throws Exception {
testLinkOtherSchema();
testLinkDrop();
testLinkSchema();
testLinkEmitUpdates();
......@@ -25,6 +26,23 @@ public class TestLinkedTable extends TestBase {
testLinkTwoTables();
}
private void testLinkOtherSchema() throws Exception {
Class.forName("org.h2.Driver");
Connection ca = DriverManager.getConnection("jdbc:h2:mem:one", "sa", "sa");
Connection cb = DriverManager.getConnection("jdbc:h2:mem:two", "sa", "sa");
Statement sa = ca.createStatement();
Statement sb = cb.createStatement();
sa.execute("CREATE TABLE GOOD (X NUMBER)");
sa.execute("CREATE SCHEMA S");
sa.execute("CREATE TABLE S.BAD (X NUMBER)");
sb.execute("CALL LINK_SCHEMA('G', '', 'jdbc:h2:mem:one', 'sa', 'sa', 'PUBLIC'); ");
sb.execute("CALL LINK_SCHEMA('B', '', 'jdbc:h2:mem:one', 'sa', 'sa', 'S'); ");
sb.executeQuery("SELECT * FROM G.GOOD"); //OK
sb.executeQuery("SELECT * FROM B.BAD"); // FAILED
ca.close();
cb.close();
}
private void testLinkTwoTables() throws Exception {
Class.forName("org.h2.Driver");
Connection conn = DriverManager.getConnection("jdbc:h2:mem:one", "sa", "sa");
......
......@@ -28,6 +28,7 @@ public class TestPreparedStatement extends TestBase {
deleteDb("preparedStatement");
Connection conn = getConnection("preparedStatement");
testInsertFunction(conn);
testPrepareRecompile(conn);
testMaxRowsChange(conn);
testUnknownDataType(conn);
......@@ -53,6 +54,26 @@ public class TestPreparedStatement extends TestBase {
conn.close();
}
private void testInsertFunction(Connection conn) throws Exception {
Statement stat = conn.createStatement();
PreparedStatement prep;
ResultSet rs;
stat.execute("CREATE TABLE TEST(ID INT, H BINARY)");
prep = conn.prepareStatement("INSERT INTO TEST VALUES(?, HASH('SHA256', STRINGTOUTF8(?), 5))");
prep.setInt(1, 1);
prep.setString(2, "One");
prep.execute();
prep.setInt(1, 2);
prep.setString(2, "Two");
prep.execute();
rs = stat.executeQuery("SELECT COUNT(DISTINCT H) FROM TEST");
rs.next();
check(rs.getInt(1), 2);
stat.execute("DROP TABLE TEST");
}
private void testPrepareRecompile(Connection conn) throws Exception {
Statement stat = conn.createStatement();
PreparedStatement prep;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论