Cannot Connect over TCP - I suck

26 views
Skip to first unread message

bxgrant

unread,
Aug 8, 2007, 3:22:13 AM8/8/07
to H2 Database
I cannot connect over tcp from a java application but can from the web
console. I must be doing something wrong. For hours now I cannot
figure out why.

1) All tests run on localhost
2) No firewall installed on windows xp dev machine
3) Installed tcp service as instructed
4) Logged into web console from browser using: jdbc:h2:tcp://localhost/
c://db/mytest
5) Saw that database was created and logged in just fine, created a
table
6) Created Test.java with this in its main method:

try
{
Class.forName("org.h2.Driver");
Connection conn = DriverManager.getConnection("jdbc:h2:tcp://
localhost/c://db/mytest", "xx", "xx");
System.out.println("**********Worked");
conn.close();
}
catch(Throwable t)
{
t.printStackTrace();
}

7) It failed with this exception:

org.h2.jdbc.JdbcSQLException: Connection is broken [90067-50]
at org.h2.message.Message.getSQLException(Message.java:65)
at org.h2.message.Message.getSQLException(Message.java:47)
at org.h2.message.Message.getSQLException(Message.java:86)
at org.h2.engine.SessionRemote.checkClosed(SessionRemote.java:245)
at org.h2.engine.SessionRemote.connect(SessionRemote.java:217)
at org.h2.engine.SessionRemote.<init>(SessionRemote.java:160)
at org.h2.engine.SessionRemote.createSession(SessionRemote.java:155)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:921)
at org.h2.Driver.connect(Driver.java:52)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
....

8) Change java application to login WITHOUT tcp and it works just fine
hitting the same database created before:

Connection conn = DriverManager.getConnection("jdbc:h2:/db/
mytest", "xx", "xx");

WHAT AM I DOING WRONG!!!! Thanks for your time.

gingda

unread,
Aug 8, 2007, 6:24:15 PM8/8/07
to H2 Database
Are you starting the db server in another process and then trying to
connect to it via tcp?

The command would look something like:

java -cp h2.jar org.h2.tools.Server -tcp

Thomas Mueller

unread,
Aug 9, 2007, 12:14:50 AM8/9/07
to h2-da...@googlegroups.com
Hi,

Yes, the server needs to be started. See also
http://www.h2database.com/html/tutorial.html#using_server

Thomas

bxgrant

unread,
Aug 9, 2007, 1:42:47 AM8/9/07
to H2 Database
Guys,

My fault. I assumed the latest h2-1.0xxx.jar in the ibiblio maven2
repository was the most current and thus would match the server I
downloaded. I was wrong. Version 1.0.20070802 wasn't there and so I
was using the wrong client jar for the server. Sorry to waste your
time. A thousand apologies.

On Aug 8, 10:14 pm, "Thomas Mueller" <thomas.tom.muel...@gmail.com>
wrote:
> Hi,
>
> Yes, the server needs to be started. See alsohttp://www.h2database.com/html/tutorial.html#using_server

Jeffrey Krzysztow

unread,
Aug 9, 2007, 11:20:18 AM8/9/07
to h2-da...@googlegroups.com
Is there anyway to have the console start a TCP server also?

Thomas Mueller

unread,
Aug 10, 2007, 2:32:20 PM8/10/07
to h2-da...@googlegroups.com
Hi,

Currently the process of updating the maven repository is manual. It
seems that more and more people are using Maven, and that from now on
every release should be added to the ibiblio repository. I will try to
automate this process.

> Is there anyway to have the console start a TCP server also?

This is done automatically when running
java org.h2.tools.Console
see also http://www.h2database.com/html/tutorial.html#using_server


Thomas

Jeffrey Krzysztow

unread,
Aug 13, 2007, 9:22:39 AM8/13/07
to h2-da...@googlegroups.com
On 8/10/07, Thomas Mueller <thomas.to...@gmail.com> wrote:
> Is there anyway to have the console start a TCP server also?

This is done automatically when running
java org.h2.tools.Console
see also http://www.h2database.com/html/tutorial.html#using_server



I have read the section and I must be dense as I do not understand what port the TCP server gets started at when the console is started.

Jeffrey

Thomas Mueller

unread,
Aug 13, 2007, 4:10:43 PM8/13/07
to h2-da...@googlegroups.com
Hi,

If you type
java org.h2.tools.Server -?
you will see that it's 9092. I will add this to the docs.

Thomas

Jeffrey Krzysztow

unread,
Aug 13, 2007, 5:12:27 PM8/13/07
to h2-da...@googlegroups.com
Now I understand and thank you!

Jeffrey
Reply all
Reply to author
Forward
0 new messages