Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebird connection with java

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.

like image 828
Rakesh Goyal Avatar asked Aug 06 '10 13:08

Rakesh Goyal


People also ask

What is Java SQL connection?

A connection (session) with a specific database. SQL statements are executed and results are returned within the context of a connection. A Connection object's database is able to provide information describing its tables, its supported SQL grammar, its stored procedures, the capabilities of this connection, and so on.

What is jaybird Firebird?

Jaybird is a JCA/JDBC driver suite to connect to Firebird database servers. This driver is based on both the JCA standard for application server connections to enterprise information systems and the well-known JDBC standard.


2 Answers

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"
like image 181
Eduardo Cuomo Avatar answered Sep 24 '22 03:09

Eduardo Cuomo


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.

like image 23
trashgod Avatar answered Sep 23 '22 03:09

trashgod