Firebird connection with java
Asked Answered
T

7

12

I have installed Firebird 2.1 on windows Xp and using firebirdsql.jdbc-2.1.6 driver to connect with java. Code:

Class.forName("org.firebirdsql.jdbc.FBDriver"); 

connection = DriverManager.getConnection(
    "jdbc:firebirdsql://localhost/3050//C:/firebird/database/EMPLOYEE.FDB", 
    "test","test"); 

I am getting following error:

Caused by: org.firebirdsql.jdbc.FBSQLException: GDS Exception. 335544375.
unavailable database 
Reason: unavailable database at 
org.firebirdsql.jdbc.FBDataSource.getConnection(FBDataSource.java:122) at 
org.firebirdsql.jdbc.FBDriver.connect(FBDriver.java:140) at 
java.sql.DriverManager.getConnection(DriverManager.java:525) at 
java.sql.DriverManager.getConnection(DriverManager.java:171)

Please help.

Problem solved: Actually I had problem with jar file that I got from

http://mirrors.ibiblio.org/pub/mirrors/maven2

I downloaded jaybird-full-2.1.6.jar from firebird offical website and problem got solved.

Correct URL is

"jdbc:firebirdsql://localhost:3050/C:\\firebird\\database\\EMPLOYEE.FDB"

I tried this URL earlier also but it was not working beacuse of jar issue.

Teleprinter answered 6/8, 2010 at 13:28 Comment(2)
Reformatted code; please revert if incorrect.Glyphography
Don't add a "Problem solved" section to the question, post it as an answer instead and accept it. Thanks!Mansfield
G
3

As @Thorbjørn Ravn Andersen observes, your Jaybird JDBC URL is incorrect. The syntax is jdbc:firebirdsql:[host[/port]:]<database>. You need a colon between the host/port and the database path. Perhaps something like this:

"jdbc:firebirdsql://localhost/3050:C:\\firebird\database\EMPLOYEE.FDB"

Oops, I left in the leading slashes; try this:

"jdbc:firebirdsql:localhost/3050:C:\\firebird\database\EMPLOYEE.FDB"

Addendum: You might run through the common errors list. Also, my firebird database files end in .fdb, but the FAQ mentions .gdb. It can't hurt to check.

Glyphography answered 6/8, 2010 at 15:23 Comment(9)
I have tried all the options including url specified by you..nothing is working..Teleprinter
Is Firebird running on port 3050? Can you connect by any other means, e.g. isql or a GUI client?Glyphography
I can connect with isql and flameRobin..it is running on 3050 port..I have tried creating a new database..switching off windows firewall..copying dll's in system 32 (as specified on firebird support group)..Teleprinter
@rakesh-nitj: Sorry, I'm running low on fresh ideas; more above.Glyphography
@trashgod:tried .gdb databases as well..anyways posted this question in firebird-java-support group..thanks for your time and efforts!Teleprinter
@rakesh-nitj: I'd like to hear how the problem gets resolved.Glyphography
@trashgod:Problem got solved. Please see the updates above. Thanks for your assistance.Teleprinter
@rakesh-nitj: Thanks for updating your question.Glyphography
@Thorbjørn Ravn Andersen: Sorry about misspelling your name. :-)Glyphography
T
3

From https://www.firebirdsql.org/file/documentation/drivers_documentation/java/faq.html#pure-java-default

Default URL format:

"jdbc:firebirdsql://host[:port]/<database>"

Deprecated, but still supported legacy URL format:

"jdbc:firebirdsql:host[/port]:<database>"

Then, the correct URL should be:

"jdbc:firebirdsql://localhost:3050/C:/firebird/database/EMPLOYEE.FDB"
Trebizond answered 30/3, 2017 at 14:0 Comment(0)
S
0

Your URL is most likely broken for this driver.

Attach actual source to the jar and set a breakpoint in FBDataSource.getConnection(...) and see what values are actually present when the connection is attempted made.

Are you absolutely certain that the combination of a hostname with port agrees with a path to the FDB-file?

Stratocracy answered 6/8, 2010 at 13:42 Comment(1)
I am absolutley sure about connection parameters along with the path of FDB file.Teleprinter
T
0

Looking at the documentation on this site: http://www.firebirdsql.org/file/documentation/drivers_documentation/java/faq.html, item 3.1

It seems that after the [port], you must have an slash "/" or double slash "//" in case you would connect on a linux server.

Tudela answered 29/5, 2014 at 2:41 Comment(0)
H
0

To connect to the database located on remote machine or cloud (linux) then use following link.

jdbc:firebirdsql:34.212.208.251/3050:/opt/app/db/sample_training.fdb

Hedger answered 14/9, 2017 at 6:23 Comment(0)
K
0

You should try this one. It works for me on Windows.

jdbc:firebirdsql://localhost:3050/C:\firebird\database\EMPLOYEE.FDB

Also make sure you added an exception for port 3050 to the Firewall.

Kiernan answered 1/4, 2019 at 11:35 Comment(0)
A
0

Connection string example for Apache Tomcat properties.xml with specified IP, port, data base alias and encoding:

<entry key="db.url">jdbc:firebirdsql:127.0.0.1/2222:my-db-alias?lc_ctype=WIN1251</entry>

Anemophilous answered 25/1, 2023 at 14:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.