Had a bash at implementing this.

Let me know if it works for you.

-- Noel Grandin

On Sun, Nov 13, 2011 at 10:17, Thomas Mueller
<[email protected]> wrote:
> Hi,
> This isn't supported currently, but it's a reasonable request. I will not
> have time to implement it myself currently, but patches are always welcome!
> Regards,
> Thomas
>
> --
> You received this message because you are subscribed to the Google Groups
> "H2 Database" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/h2-database?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

Index: src/docsrc/html/changelog.html
===================================================================
--- src/docsrc/html/changelog.html      (revision 3994)
+++ src/docsrc/html/changelog.html      (working copy)
@@ -32,6 +32,7 @@
     was aliased in the select list.
 </li><li>Issue 326: improved support for case sensitive (mixed case) 
identifiers 
     without quotes when using DATABASE_TO_UPPER=FALSE.
+</li><li>Add JDBC URL parameter to control server port when in AUTO_SERVER mode
 </li></ul>
 
 <h2>Version 1.3.161 (2011-10-28)</h2>
Index: src/docsrc/html/features.html
===================================================================
--- src/docsrc/html/features.html       (revision 3994)
+++ src/docsrc/html/features.html       (working copy)
@@ -1189,7 +1189,10 @@
 // Application 2:
 DriverManager.getConnection("jdbc:h2:/data/test;AUTO_SERVER=TRUE");
 </pre>
-
+<p>
+By default the server allocates a random TCP socket. 
+It is possible to control the port that the server uses by passing in an 
AUTO_SERVER_PORT=xxx parameter.
+</p>
 <h2 id="page_size">Page Size</h2>
 <p>
 The page size for new databases is 2 KB (2048), unless the page size is set
Index: src/main/org/h2/engine/Database.java
===================================================================
--- src/main/org/h2/engine/Database.java        (revision 3994)
+++ src/main/org/h2/engine/Database.java        (working copy)
@@ -152,6 +152,7 @@
     private int maxOperationMemory = Constants.DEFAULT_MAX_OPERATION_MEMORY;
     private SmallLRUCache<String, String[]> lobFileListCache;
     private boolean autoServerMode;
+    private int autoServerPort;
     private Server server;
     private HashMap<TableLinkConnection, TableLinkConnection> linkConnections;
     private TempFileDeleter tempFileDeleter = TempFileDeleter.getInstance();
@@ -189,6 +190,7 @@
         String lockMethodName = ci.getProperty("FILE_LOCK", null);
         this.accessModeData = 
StringUtils.toLowerEnglish(ci.getProperty("ACCESS_MODE_DATA", "rw"));
         this.autoServerMode = ci.getProperty("AUTO_SERVER", false);
+        this.autoServerPort = ci.getProperty("AUTO_SERVER_PORT", 0);
         this.cacheSize = ci.getProperty("CACHE_SIZE", 
Constants.CACHE_SIZE_DEFAULT);
         this.pageSize = ci.getProperty("PAGE_SIZE", 
Constants.DEFAULT_PAGE_SIZE);
         if ("r".equals(accessModeData)) {
@@ -636,7 +638,7 @@
     private void startServer(String key) {
         try {
             server = Server.createTcpServer(
-                    "-tcpPort", "0",
+                    "-tcpPort", "" + autoServerPort,
                     "-tcpAllowOthers",
                     "-tcpDaemon",
                     "-key", key, databaseName);

Reply via email to