提交 725532f8 authored 作者: Thomas Mueller's avatar Thomas Mueller

ODBC: additional connection settings can now be added to the database name.

上级 91e00175
......@@ -524,22 +524,23 @@ By default, only connections from localhost are allowed. To allow remote connect
After installing the driver, a new Data Source must be added. In Windows,
run <code>odbcad32.exe</code> to open the Data Source Administrator. Then click on 'Add...'
and select the PostgreSQL Unicode driver. Then click 'Finish'.
You will be able to change the connection properties:
You will be able to change the connection properties.
The property column represents the property key in the <code>odbc.ini</code> file
(which may be different from the GUI).
</p>
<table>
<tr><th>Property</th><th>Example</th><th>Remarks</th></tr>
<tr><td>Data Source</td><td>H2 Test</td><td>The name of the ODBC Data Source</td></tr>
<tr><td>Database</td><td>test</td>
<tr><td>Database</td><td>~/test;ifexists=true</td>
<td>
The database name. Only simple names are supported at this time; <br />
relative or absolute path are not supported in the database name. <br />
The database name. This can include connections settings.<br />
By default, the database is stored in the current working directory <br />
where the Server is started except when the -baseDir setting is used. <br />
The name must be at least 3 characters.
</td></tr>
<tr><td>Server</td><td>localhost</td><td>The server name or IP address.<br />By default, only remote connections are allowed</td></tr>
<tr><td>User Name</td><td>sa</td><td>The database user name.</td></tr>
<tr><td>SSL Mode</td><td>disabled</td><td>At this time, SSL is not supported.</td></tr>
<tr><td>Servername</td><td>localhost</td><td>The server name or IP address.<br />By default, only remote connections are allowed</td></tr>
<tr><td>Username</td><td>sa</td><td>The database user name.</td></tr>
<tr><td>SSL</td><td>false (disabled)</td><td>At this time, SSL is not supported.</td></tr>
<tr><td>Port</td><td>5435</td><td>The port where the PG Server is listening.</td></tr>
<tr><td>Password</td><td>sa</td><td>The database password.</td></tr>
</table>
......
......@@ -18,7 +18,9 @@ Change Log
<h1>Change Log</h1>
<h2>Next Version (unreleased)</h2>
<ul><li>Local temporary tables can now be created without having to commit a transaction
<ul><li>ODBC: additional connection settings can now be added to the database name.
Example: ~/test;cipher=xtea. Therefore, encrypted databases are supported.
</li><li>Local temporary tables can now be created without having to commit a transaction
using CREATE LOCAL TEMPORARY TABLE TEMP(ID INT PRIMARY KEY) TRANSACTIONAL.
</li><li>New system property h2.dropRestrict (default false) to change the
default action for DROP TABLE and DROP VIEW (false for CASCADE, true for RESTRICT).
......
......@@ -514,6 +514,7 @@ See also <a href="build.html#providing_patches">Providing Patches</a>.
</li><li>User defined aggregate: allow declaring as source code (like functions).
</li><li>The error "table not found" is sometimes caused by using the wrong database.
Add "(this database is empty)" to the exception message if applicable.
</li><li>PostgreSQL compatibility: support escape with double \\.
</li></ul>
<h2>Not Planned</h2>
......
......@@ -243,7 +243,7 @@ public class ConnectionInfo implements Cloneable {
* Split the password property into file password and user password if
* necessary, and convert them to the internal hash format.
*/
public void convertPasswords() {
private void convertPasswords() {
char[] password = removePassword();
SHA256 sha = new SHA256();
if (getProperty("CIPHER", null) != null) {
......
......@@ -27,6 +27,7 @@ import java.sql.SQLException;
import java.sql.Statement;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Properties;
import org.h2.constant.SysProperties;
import org.h2.engine.ConnectionInfo;
import org.h2.jdbc.JdbcConnection;
......@@ -155,10 +156,13 @@ public class PgServerThread implements Runnable {
} else if ("database".equals(param)) {
this.databaseName = value;
} else if ("client_encoding".equals(param)) {
// UTF8
clientEncoding = value;
} else if ("DateStyle".equals(param)) {
dateStyle = value;
}
// extra_float_digits 2
// geqo on (Genetic Query Optimization)
server.trace(" param " + param + "=" + value);
}
sendAuthenticationCleartextPassword();
......@@ -169,7 +173,12 @@ public class PgServerThread implements Runnable {
server.trace("PasswordMessage");
String password = readString();
try {
ConnectionInfo ci = new ConnectionInfo(databaseName);
Properties info = new Properties();
info.put("MODE", "PostgreSQL");
info.put("USER", userName);
info.put("PASSWORD", password);
String url = "jdbc:h2:" + databaseName;
ConnectionInfo ci = new ConnectionInfo(url, info);
String baseDir = server.getBaseDir();
if (baseDir == null) {
baseDir = SysProperties.getBaseDir();
......@@ -180,11 +189,6 @@ public class PgServerThread implements Runnable {
if (server.getIfExists()) {
ci.setProperty("IFEXISTS", "TRUE");
}
ci.setProperty("MODE", "PostgreSQL");
ci.setOriginalURL("jdbc:h2:" + databaseName + ";MODE=PostgreSQL");
ci.setUserName(userName);
ci.setProperty("PASSWORD", password);
ci.convertPasswords();
conn = new JdbcConnection(ci, false);
// can not do this because when called inside
// DriverManager.getConnection, a deadlock occurs
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论