You are not logged in.

Dani

Intermediate

  • "Dani" started this thread

Posts: 325

Date of registration: Nov 19th 2009

Location: GERMANY

  • Send private message

1

Wednesday, October 22nd 2014, 11:27am

H2 Database /tcpServer / Java array

Hey there,

I am trying to set up a tcpServer from within a Jabaco App to remotely connect to a database file.
Here is the Java code:

Source code

1
2
3
4
5
6
7
8
9
10
11
'h2 server class
'https://code.google.com/p/h2database/source/browse/trunk/h2/src/main/org/h2/server/TcpServer.java
'Java:
   // start the server, allows To access the database remotely
   Import org.h2.Driver;
   Import org.h2.tools.Server;
   String args[] = {"-tcpAllowOthers", "true", "-tcpPort", "9092", "-baseDir", "C:/test"}; 
   Server server = Server.createTcpServer(args);
   Server.start();
   Class.forName("org.h2.Driver"); 
   conn = DriverManager.getConnection("jdbc:h2:tcp://" + ipAddress + "//databasename", userName, pwdString);


and my Jabaco approach:

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
Option Explicit

Import org#h2#Driver
Import org#h2#tools#Server

Dim conn As java#sql#Connection 
Dim st As java#sql#Statement

Public Sub Form_Load()

   java#lang#Class.forName("org.h2.Driver")

'   Dim args() As String 
'   args() = Split("-tcpAllowOthers, True, -tcpPort, 9092, -baseDir, C:/" , ",")

   'Java array
   Dim args(5) As java#lang#String '= ("-tcpAllowOthers", "true", "-tcpPort", "9092", "-baseDir", "C:/test")
   
   args(0) = "-tcpAllowOthers"
   args(1) = "true"
   args(2) = "-tcpPort"
   args(3) = "9092"
   args(4) = "-baseDir"
   args(5) = "C:/test"

   'start the pure TCP Server
   'Error: Function or Variable not defined!
   Dim tcpServer As org#h2#tools#Server '= tcpServer.createTcpServer(args()).start()
   
   'Error: Method 'createTcpServer' not found with this parameters!
   tcpServer.createTcpServer(args()).start()

   'connect to the server, could be from any client
   conn = java#sql#DriverManager.getConnection("jdbc:h2:tcp://localhost/C:/test", "sa", "")
   st = conn.createStatement()

End Sub


I am getting the following Error on this

Quoted


"Method 'createTcpServer' not found with this parameters!"


My guess is that I do not use the java#lang#String array correctly!

Source code

1
   String args[] = {"-tcpAllowOthers", "true", "-tcpPort", "9092", "-baseDir", "C:/test"}; 


Could someone help to convert the original Java please...


Dani


By the way the h2 MixxedMode works fine and the client connects to the server. h2 starts the server internally here!
Still I'd like to be able to use the pure server mode.

Rate this thread
WoltLab Burning Board