火鸟与java的连接
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3424206/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Firebird connection with java
提问by Rakesh Goyal
I have installed Firebird 2.1 on windows Xp and using firebirdsql.jdbc-2.1.6 driver to connect with java. Code:
我已经在 Windows Xp 上安装了 Firebird 2.1 并使用 firebirdsql.jdbc-2.1.6 驱动程序与 java 连接。代码:
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
问题已解决:实际上我遇到了来自 jar 文件的问题
http://mirrors.ibiblio.org/pub/mirrors/maven2
http://mirrors.ibiblio.org/pub/mirrors/maven2
I downloaded jaybird-full-2.1.6.jar from firebird offical website and problem got solved.
我从firebird官方网站下载了jaybird-full-2.1.6.jar,问题解决了。
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.
我之前也尝试过这个 URL,但由于 jar 问题,它不起作用。
回答by Thorbj?rn Ravn Andersen
Your URL is most likely broken for this driver.
此驱动程序的 URL 很可能已损坏。
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.
将实际源附加到 jar 并在 FBDataSource.getConnection(...) 中设置断点,然后查看尝试建立连接时实际存在的值。
Are you absolutely certain that the combination of a hostname with port agrees with a path to the FDB-file?
您绝对确定主机名和端口的组合与 FDB 文件的路径一致吗?
回答by trashgod
As @Thorbj?rn Ravn Andersen observes, your Jaybird JDBC URLis 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:
正如@Thorbj?rn Ravn Andersen 所观察到的,您的Jaybird JDBC URL不正确。语法是jdbc:firebirdsql:[host[/port]:]<database>
. 主机/端口和数据库路径之间需要一个冒号。也许是这样的:
"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 errorslist. Also, my firebird database files end in .fdb
, but the FAQ mentions .gdb
. It can't hurt to check.
附录:您可能会浏览常见错误列表。另外,我的Firebird数据库文件结束.fdb
,但常见问题解答中提到.gdb
。检查不会有什么坏处。
回答by Fernando Vieira
Looking at the documentation on this site: http://www.firebirdsql.org/file/documentation/drivers_documentation/java/faq.html, item 3.1
查看此站点上的文档:http: //www.firebirdsql.org/file/documentation/drivers_documentation/java/faq.html,第 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.
似乎在 [port] 之后,您必须有一个斜杠“/”或双斜杠“//”,以防您在 linux 服务器上进行连接。
回答by Eduardo Cuomo
From https://www.firebirdsql.org/file/documentation/drivers_documentation/java/faq.html#pure-java-default
来自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:
已弃用,但仍支持旧版 URL 格式:
"jdbc:firebirdsql:host[/port]:<database>"
Then, the correct URL should be:
然后,正确的 URL 应该是:
"jdbc:firebirdsql://localhost:3050/C:/firebird/database/EMPLOYEE.FDB"
回答by Mayur Lokare
To connect to the database located on remote machine or cloud (linux) then use following link.
要连接到位于远程机器或云 (linux) 上的数据库,请使用以下链接。
jdbc:firebirdsql:34.212.208.251/3050:/opt/app/db/sample_training.fdb
jdbc:firebirdsql:34.212.208.251/3050:/opt/app/db/sample_training.fdb
回答by tjlee
You should try this one. It works for me on Windows.
你应该试试这个。它在 Windows 上对我有用。
jdbc:firebirdsql://localhost:3050/C:\firebird\database\EMPLOYEE.FDB
Also make sure you added an exception for port 3050 to the Firewall.
还要确保为防火墙添加了端口 3050 的例外。