How to setup Embedded Firebird and access from Java Application? - firebird

I have a Firebird DB file, test.fdb in some directory, I want to access the DB from java application. What are the required libraries files to access.
I am using Jaybird JDBC Driver to access the embedded Firebird database, but I'm getting the error
Exception in thread "main" java.lang.UnsatisfiedLinkError: no
jaybird22_x64 in java.library.path
I tried downloading and adding the jaybird22_x64.so file by System.setProperty("java.library.path", "/home/sk/Desktop/Jaybird/");
and also with System.load() and -Djava.library.path
The jaybird folder contains the file jaybird22_x64.so file.
I am using Ubuntu 17.04, with kernel 4.10.0-42-generic
Here is the exception I get.
Exception in thread "main" java.lang.UnsatisfiedLinkError: no
jaybird22_x64 in java.library.path at
java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867) at
java.lang.Runtime.loadLibrary0(Runtime.java:870) at
java.lang.System.loadLibrary(System.java:1122) at
org.firebirdsql.gds.impl.jni.JniGDSImpl.initJNIBridge(JniGDSImpl.java:64)
at
org.firebirdsql.gds.impl.jni.JniGDSImpl.(JniGDSImpl.java:25)
at
org.firebirdsql.gds.impl.jni.EmbeddedGDSFactoryPlugin.getGDS(EmbeddedGDSFactoryPlugin.java:40)
at
org.firebirdsql.gds.impl.GDSFactory.getGDSForType(GDSFactory.java:275)
at
org.firebirdsql.jca.FBManagedConnectionFactory.getGDS(FBManagedConnectionFactory.java:123)
at
org.firebirdsql.jdbc.AbstractDriver.connect(AbstractDriver.java:130)
at java.sql.DriverManager.getConnection(DriverManager.java:664) at
java.sql.DriverManager.getConnection(DriverManager.java:247) at
test.TestJavaFireBird.main(TestJavaFireBird.java:33)
Can anyone help, what libraries are required and how to load them?

It looks like the binaries from the Firebird website don't work on Ubuntu. So to use Firebird embedded on Ubuntu 17.04, the simplest is to install Firebird 3.0 server using:
sudo apt-get install firebird3.0-server
In the install, make sure to enter a password for the sysdba account.
This will install and start a full Firebird 3.0 server, but the alternative is to compile Firebird yourself. You can stop and disable the server process using
sudo systemctl stop firebird3.0
sudo systemctl disable firebird3.0
Next, you will need to add yourself to the Firebird group to get access to /tmp/firebird for the shared lock-files:
sudo usermod -a -G firebird <your-username>
Reboot to get access to the group. This shouldn't be necessary, but I couldn't get the group without a reboot on my machine.
After getting this working, you can try to get it working without adding yourself to the firebird group by specifying the lock-path using the FIREBIRD_LOCK environment variable.
Next use Jaybird 3.0 and JNA 4.4.0 to run your Java application. If you want to use Jaybird 2.2, you will need to compile the libjaybird22_x64.so yourself.
If you really need to use Firebird 2.5, then you may want to look at https://askubuntu.com/questions/945327/how-to-installing-firebird-on-ubuntu-16-04 although I'm not sure this will still work on 17.04.

Related

postgres odbc connection fails

I am trying to set up a new postgres odbc connection for an application.
This is done on 32-bit Windows 7 system. I installed latest postgresql 9.6 & psqlodbc 0905, and there were no errors. When I add the odbc connection string and test connectivity with postgres login, it fails with the following error:
Test connection failed because of an error in initialized provider.
Specified driver could not be loaded due to system error 182:
(PostgreSQL UNICODE, C:\Program
Files\psqlODBC\0905\bin\psqlodbc35w.dll)
Here's the connection string:
Driver={PostgreSQL
UNICODE};Server=127.0.0.1;Port=5432;Database=postgres;
Uid=postgres;Pwd=postgres;
I then installed Visual C++ redistributable packager versions 2008 and 2010 later. Rebooted the box. Still same issue.
Postgres + odbc + other installs were complete and without any errors.
This is getting too frustrating.
Please.. any ideas on how to fix this will be helpful.?!
Update: I have tested the following:
1. Installed older postgres & psdqlodbc version
2. Added psqlodbc path to PATH env variable at the start
3. Uninstalled standalone psqlodbc installs, and installed Stackbuilder from postgresql package to download and install psqlodbc component.
All of these have not not been any useful.
Final Update: I was able to fix this by using psqlodbc_09_03_0400. For whatever reason, other versions kept throwing error.
Apparently, according to the Microsoft index of error codes, error 182 means ERROR_INVALID_ORDINAL, which with the help of this answer I believe means that the postgresql ODBC driver is loading another DLL and trying to call a function within it that does not exist.
The most likely cause for this would be that the system is loading a wrong version of a DLL on which psqlodbc depends. In fact I found this thread where someone else was having the same issue (although back in 2005).
This could happen if you had installed some other package containing one of the DLLs that psqlodbc relies on, or maybe even another version of psqlodbc.
Try changing the windows search path to put the directory containing the psqlodbc drivers at the front to confirm if this is the case. If that works you might want to try to narrow the problem down until you can find exactly what DLL is conflicting, and if possible remove it.
It is also possible that there is some packaging issue with the psqlodbc package you are using - if that is the case you could try uninstalling that one and installing an earlier version.
Final Update: I was able to fix this by using psqlodbc_09_03_0400. For whatever reason, other versions kept throwing error.

Freeradius 3.0.11 Postgresql

I'm trying to configure freeradius 3.0.11 with postgresql but I'm having an issue with the driver listed in the sql file inside of 'mods-enabled.' The driver I am listing is 'rlm_sql_postgresql.'
When I run 'radiusd -X' I get the error:
Could not link driver rlm_sql_postgresql: dlopen(/usr/local/Cellar/freeradius-
server/3.0.11/lib/rlm_sql_postgresql.dylib, 6): image not found
Make sure it (and all its dependent libraries!) are in the search path of your system's ld
/usr/local/Cellar/freeradius-server/3.0.11/etc/raddb/mods-enabled/sql[20]: Instantiation failed for module "sql"
When I look in the folder 3.0.11/lib there is indeed no such file called rlm_sql_postgresql.dylib.
Any ideas on this? Should I be generating this file somehow?
It means when configure was run for freeradius, it didn't pick up libpq.
Apparently brew install postgresql will pull down libpq and its development headers.
Remove freeradius, install postgresql, install freeradius with brew install --build-from-source freeradius-server
It should (unless the homebrew people have gone out of their way to break things), install the postgresql driver.

Laravel login from sqlite DB, getting "PDOException could not find driver"

I am trying to write a simple login form using Laravel and sqlite DB on localhost (vagrant and virtualbox). However, after entering username and passoword I keep getting "PDOException could not find driver" error. Any ideas?
--- EDIT ---
Had to install sqlite driver by typing
sudo apt-get install php5-sqlite
in my terminal window. It was somehow not enabled by default :/
It sounds like your version of PHP is either missing, or has disabled, the PDO extension. Use the phpinfo function to list out the extensions installed and enabled. If PDO isn't there, look for a commented line in your php.ini file(s) and/or talk to the person maintaining your servers.
Your system has missing php SQLite installation.
Install it by using:
sudo apt-get install php7.0-sqlite

PostgreSQL seems to be using an old version after update

I uninstalled my PostgreSQL because I'm trying to use version 9.1.9. I tried reinstalling it. It successfully installed from what I can see.
However, when typing in psql --version on the command line, I get that it is still using version 9.0.10
How can I make it use the new version?
psql is the command line interface and its version can be independent of the Postgres server.
To get the version of the server software run SELECT version() against the database you are connected to (from within psql). Though it is possible to interact with different versions, some obvious limitations apply. I suggest you uninstall the outdated psql as well and use the version matching the server.
If you're running this on a UNIX/Linux system the problem is likely to do with where psql is being called from. It doesn't sound like the old version got removed and you're still calling it when you run psql. Try running this:
which psql
That will tell you the full path of what gets invoked when you run just psql. To see if there are other instances of psql installed on your system try running:
sudo updatedb
(you'll need to put in your password here). And then:
locate psql
Your system likely uses some kind of package manager, which controls which packages are installed. For example, Ubuntu/Debian use dpkg, Redhat uses yum, you may be using something like fink or macports if you are using OSX.

PostgreSQL failure on test database for Rails application

Upon running rake db:test:prepare my test database was dropped, but failed to be rebuilt. After researching the errors, I simply attempted to load the database with rake db:test:load to repopulate based on the schema.rb file. That call resulted in the following message
PG::Error: ERROR: could not open extension control file "/usr/pgsql-9.1/share/extension/postgis.control": No such file or directory
I've spent the day reinstalling postgresql-9.1 and postGIS 1.5.3 on a test server in every way I can find on the internet, and none of those installations produce the ever-elusive postgis.control file. Is there a special install I need to run on a CentOS6 machine to produce the binary? Or is there another way to run the rake tasks to test the psql database?
This message is shown for CREATE EXTENSION postgis; however the newer extension method was introduced for PostGIS 2.0. The version that you have installed does not support this method.
Either upgrade to PostGIS 2.0 (excellent RPMs for YUM here), or spatially enable a PostGIS 1.5 database using either a template or using enabler scripts. Details here.