We will create in a few easy steps a Firebird Connection Pool on GlassFish 2.1.1.
First of all, we need to download the latest jdbc driver from:
http://www.firebirdsql.org/index.php?op=files&id=jaybird
Extract the downloaded archive and take the jaybird-full-x.x.x.jar from the compressed archive and put in {glassfish}/lib directory and restart glassfish:
asadmin stop-domain domain1
asadmin start-domain domain1
Now we need to navigate to the administrator application:
http://localhost:4848/
Open the 'Resources' -> 'JDBC' -> 'Connection Pools' and select 'New.
Fill in the Connection Pool 'Name'.
Select 'Resource Type' : 'javax.sql.ConnectionPoolDataSource'.
Select 'Next'.
At the next page complete the 'Datasource Classname' with :
org.firebirdsql.pool.sun.AppServerConnectionPoolDataSource
Then go down at the additional Properties.
Find and edit the following properties :
Select 'Name' : 'userName' and 'Value' : {db_user}
Select 'Name' : 'password' and 'Value' : {db_user_pass}
Select 'Name' : 'databaseName' and 'Value' : {host_name}:{db_path}
for example:
localhost:/my_data_files/mydb.fdb
Select 'Finish'.
Navigate to Connection Pools and select the pool you just created.
Click Ping to test that it is working. If it is not, it is probably because you have mistyped the connection credentials. Go to 'Additional Properties' tab of the connection pool detail page and correct any errors. Try ping again.
Open the 'Resources' -> 'JDBC' -> 'JDBC Resources' and select 'New.
Fill the JNDI Name like 'jdbc/myconnnection'.
Select from 'Pool Name' combo box the pool we just created.
And select 'OK'.
The Connection Pool is ready!
p.s.
You can find me on fiverr for more personalized requests on any java app server configuration problem or java error that you encounter, with deliverance of less than a day (true!) and money back guarantee if not satisfied.
First of all, we need to download the latest jdbc driver from:
http://www.firebirdsql.org/index.php?op=files&id=jaybird
Extract the downloaded archive and take the jaybird-full-x.x.x.jar from the compressed archive and put in {glassfish}/lib directory and restart glassfish:
asadmin stop-domain domain1
asadmin start-domain domain1
Now we need to navigate to the administrator application:
http://localhost:4848/
Open the 'Resources' -> 'JDBC' -> 'Connection Pools' and select 'New.
Fill in the Connection Pool 'Name'.
Select 'Resource Type' : 'javax.sql.ConnectionPoolDataSource'.
Select 'Next'.
At the next page complete the 'Datasource Classname' with :
org.firebirdsql.pool.sun.AppServerConnectionPoolDataSource
Then go down at the additional Properties.
Find and edit the following properties :
Select 'Name' : 'userName' and 'Value' : {db_user}
Select 'Name' : 'password' and 'Value' : {db_user_pass}
Select 'Name' : 'databaseName' and 'Value' : {host_name}:{db_path}
for example:
localhost:/my_data_files/mydb.fdb
Select 'Finish'.
Navigate to Connection Pools and select the pool you just created.
Click Ping to test that it is working. If it is not, it is probably because you have mistyped the connection credentials. Go to 'Additional Properties' tab of the connection pool detail page and correct any errors. Try ping again.
Open the 'Resources' -> 'JDBC' -> 'JDBC Resources' and select 'New.
Fill the JNDI Name like 'jdbc/myconnnection'.
Select from 'Pool Name' combo box the pool we just created.
And select 'OK'.
The Connection Pool is ready!
p.s.
You can find me on fiverr for more personalized requests on any java app server configuration problem or java error that you encounter, with deliverance of less than a day (true!) and money back guarantee if not satisfied.
I'm making a connection with jaybird 2.1.5 e glassfish 2.1.1, instaled jaybird domains/domain1/lib folder and click ping when it shows the following error:
ReplyDeleteClass name is wrong or classpath is not for: org.firebirdsql.pool.sun.AppServerDataSurce
My friend teste. You need to put the jaybird jdbc library in {GlassFish_Home}/lib directory, and restart. I believe this will solve your problem.
ReplyDeleteHi. Just like to thank you on this great explanation. You've helped me a lot. Thank you.
ReplyDeleteHi, i´m using Glassfish 3 and firebird 2.5 with jaybird 2.1.6JDK6. Ping is ok and log show:
ReplyDelete[#|2010-11-05T16:06:31.156-0600|WARNING|glassfish3.0.1|javax.enterprise.resource.resourceadapter.com.sun.gjc.spi|_ThreadID=26;_ThreadName=Thread-1;|RAR7114: Unable to get ClientInfo for connection
java.sql.SQLException: not yet implemented
at org.firebirdsql.jdbc.FBConnection.getClientInfo(FBConnection.java:268) .................
the class of persistence no return data and no crash
ide netbeans 6.9
Anonymous friend,
ReplyDeleteI have found a [minor - fixed - closed] bug [- improvement ] in jaybird's tracker that references your problem. You can follow it here:
http://tracker.firebirdsql.org/browse/JDBC-126
I would suggest to ignore it, if everything else works fine. The new version 2.2 of JayBird will not have this problem. Then you can upgrade and get rid of it.
If your log is full of these warnings you could remove them from the logger with classname : javax.enterprise.resource.resourceadapter.com.sun.gjc.spi and level SEVERE.
minha conexao so funcionou assim:
ReplyDelete//localhost:3050/{path.to.database}
Dear friend,
ReplyDeleteI don't speak spanish, but I'll give you an example:
localhost:/my_data_files/mydb.fdb
I don't think there is any need for a port. It's just a file. There is no port listener.
Take care.
Dear komarios! U've made my day, helping me to create connection to my FB! Thank you a lot!
ReplyDeleteCan you please explain the need of supplying jaybird-full instead of jaybird-pool lib?
Dear Tigra,
ReplyDeleteThank you for your kind words.
Truth be told, I did not realize there was a jaybird-pool.jar lib in the package. I would gladly update my post, if you provide me with feedback in case it works with that lib as well.
And there is also a lengthy faq inside the package at docs\faq.html, that is really helpful.
Cheers.
I guess 3050 is the default port for firebird, like 3306 is the default for MySQL.
ReplyDeleteI tried both
localhost:C:\path_to_db
and
localhost/3050:C:\path_to_db
and both worked.
In firebird FAQ the connection string used in the example is something like this:
---
Class.forName("org.firebirdsql.jdbc.FBDriver");
Connection conn = DriverManager.getConnection("jdbc:firebirdsql:localhost/3050:/firebird/test.gdb", "sysdba", "masterkey");
or "...localhost/3050:C:\\firebird\\test.gdb..." in Windows
---
I still wonder why it does not work to use in Glassfish the resource type 'javax.sql.DataSource'
with the class 'org.firebirdsql.pool.FBWrappingDataSource'
or with the class
'org.firebirdsql.jdbc.FBDataSource'.
It is written in the FB API that both implements javax.sql.DataSource...
Anyway, thank you for the example. It helped me a lot.
I have a problem. I followed all instructions and the Ping succeded...
ReplyDeleteBut now, I need to have a java WebService, deployed in glassfish, which access the firebird database to retrieve some information. However, the connection does not work.
By the way, this same WS works with MySQL, but do not works with Firebird. I need to know what is wrong...
Here is the connection class used by the WS.
-----
public class MyDAO {
protected DataSource ds;
protected InitialContext ctx;
protected Connection conn;
protected Connection getConnection() {
if (conn == null) {
try {
ctx = new InitialContext();
ds = (DataSource) ctx.lookup("jdbc/test");
conn = ds.getConnection();
} catch (NamingException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
}//endif
return conn;
}
-----
The program throws an AbstractMethodError when it tries to execute the third line
( ... conn = ds.getConnection ).
I would like to know why...
Of course, the webservice is successfully deployed. The same WS works with mysql but do not works with FireBird.
I am using Glassfish 3.1, Firebird 2.5 and the jaybird full 2.1.6.
My friend Rodrigo,
ReplyDeleteI can not think of any reason why it should not work with FireBird. All I can do is urge you to carefully check the connection pool properties in case of spelling mistakes. Then make sure that you can ping the Firebird DB through GlassFish GUI. And if the problem persists, paste the full Exception stack trace here, and i will see it again.
Cheers.
Man.... I made a small test application just to show you, then I tested it and then... it works...
DeleteI wonder why it did not work before... I think there was some problem in the database file... or in the jaybird.jar, since I recreated the database and re-downloaded the jaybird.jar
The connection code and the glassfish parameters were absolutaly the same as the ones I tried before.
Well, anyway thanks!
I am glad it worked. It could have been a corrupted jar. It has happened before.Or corrupted database file.
ReplyDeleteCheers
Thank you my friend!
ReplyDeleteHe saved my skin! I was about to give up using the firebird!