How to connect to Firebird using LibreOffice - java

I have to create some reports using LibreOffice. I need to connecto a Firebird database using JDBC. I installed the driver (adding it to the classpath) and configured my connection to use
firebirdsql://server:alias
org.firebirdsql.jdbc.FBDriver
when I test the class I get this error:
"could not load driver class org.firebirdsql.jdbc.FBDriver"
javax/resource/ResourceException
I tried in another machine and got the same message. Is there anything extra that should be added to classpath? What I´m missing here? I have both JRE and JDK installed and I´m using the first located in C:\Program Files(x86)\Java\jre7. There is no classpath environment variable defined nor global or for the user

The above continues to be correct for Jaybird 4.0. Here are instructions in a little more detail, based on Debian 10. This is for an existing Firebird database that you can access already (i.e. can connect to and have an established username and perhaps pw).
Start LibreOffice but not Base - use Calc or just the general LibreOffice icon. Go to Tools, Options, LibreOffice and click on Advanced (in the top section, not in the Base options). Check the version number of the installed JRE. Leave the Advanced window open.
Download the corresponding version of the Jaybird zip file and unpack it. As pointed out by Mark Rotteveel in the original answer, jaybird has a dependency which may mean the bare jar file won't work. The simplest way around that is to use the "full" jar file:
jaybird-full-4.0.0.java11.jar
You may wish to move it into /usr/share/java for consistency but will probably need root permissions to do so.
Back in LibreOffice, click on the Class Path button in the Advanced window, then on Add Archive and add the .jar file. Close the Advanced window and restart LibreOffice.
Connecting: start LO Base. The Database Connect Wizard will appear. Select
"Connect to an existing database". Specify JDBC as the driver and click Next.
Base supplies the jdbc: portion of the connect string, so add
firebirdsql:oo://host[:port]//<path to database file>
So, for example:
firebirdsql:oo://localhost:3050//home/dave/Firebird/employee.fdb
Note two occurances of "//" when using a full path.
When using an alias, there's only one set:
firebirdsql:oo://localhost:3050/employee
The JDBC driver class is:
org.firebirdsql.jdbc.FBDriver
Click Test Class to confirm that it is working. If not, retrace the steps above. The class test is independent of the connection string so no need to fill in both as you troubleshoot.
From that point on it should be self-evident. You'll end up with a .odb file that you can use to create Views, Reports, etc. on the industrial-strength Firebird back end.

Jaybird has a required dependency on JCA (Java Connector Architecture), specifically JCA 1.5 (although newer should work as well), as documented in the Jaybird 2.2.5 releasenotes,
This means you need to include either connector-api-1.5.jar (from the lib folder) on the classpath, or you need to use jaybird-full-2.2.5.jar as that includes the classes from connector-api-1.5.jar.
Also your url is incorrect on two things: The format of the url is
jdbc:firebirdsql[:<subprotocol>]://<host>[:<port>]/<path-or-alias>
Which mean that :alias is wrong (it should be /alias). And as also remarked by Gord Thompson in the comments, you need to use the subprotocol oo, so you need to use protocol prefix jdbc:firebirdsql:oo to address difference in interpretation on JDBC, as also documented here. So your url should probably look like:
jdbc:firebirdsql:oo://server/alias

Related

Spark: How to obtain the location of configurations spark is using?

Right now, I am running into the following issue exactly. Specifically, spark-submit is attempting to connect to the yarn.resourcemanager at location 0.0.0.0/0.0.0.0.
I have checked all of the logs delineated in the stack overflow thread above. They all seem to be correct. I have also added in a yarn.resourcemanager.address=... line to the default settings files at the top of the spark configuration directories, exported YARN_CONF_DIR and all of the other fixes listed on that thread.
At the bottom of the comments in the top rated answer, a commentator pointed out that if none of the above fixes work, then spark is not using the correct configurations.
At this point, I am pretty sure that my spark install is not using the correct configurations (I did not install it).
How does one go about determining which configurations spark is using, and how does one change them to the correct configurations? (or maybe I just need to reboot the machine?)
In spark-shell for example, I can do this:
scala> getClass.getClassLoader.getResource("yarn-site.xml")
res1: java.net.URL = file:/etc/spark2/conf.cloudera.spark2_on_yarn/yarn-conf/yarn-site.xml
...and the result shows the exact resolved location of a config file from my current classpath. Same could be easily translated to Java (almost verbatim) if your application is Java-based.
You can try to access creationSite field on org.apache.spark.sql.SparkSession through debugger or through reflection. Then you can try to find class and place in code where your spark session is created and then you can try to find how org.apache.spark.sql.SparkSession.Builder is called.

Which MySQL connector do I use: mysql-connector-java-5.1.46.jar or mysql-connector-java-5.1.46-bin.jar What is the difference?

I am preparing to use jdbc for the first time and am in the process of installing the jdbc driver for MySQL.
However, it is unclear to me which of these files to move to the WEB_INF/lib folder in Eclipse. They both seem to contain the same content and are included together in the downloaded zip file for the MySQL connector.
I have searched everywhere but have been unable to find any documentation to explain which of these files to use.
I thought you were joking, but I just downloaded the zip from https://dev.mysql.com/downloads/connector/j/ and, indeed, it contains both.
The mysql-connector-java-5.1.46.jar and mysql-connector-java-5.1.46-bin.jar are binary identical, except for the META-INF/INDEX.LIST (which contains the actual jar filename). I have unzipped both and compared them using kdiff3.
In short: you can use either: whatever you prefer.
This change is mentioned in CHANGES as:
- Fix for Bug#27231383, PROVIDE MAVEN-FRIENDLY COMMERCIAL PACKAGES WITHOUT "-BIN".
Interestingly, there is no bug 27231383 in the MySQL bug tracker (the number is too high for the 'normal' bugs listed), so maybe it is from another system within Oracle.
In addition, the online Connector/J 5.1.46 release notes mentions:
The bundle for Connector/J 5.1 delivered by Oracle now contains an
additional jar package with the name mysql-connector-java-5.1.ver.jar
(mysql-connector-java-commercial-5.1.ver.jar for commercial
bundles). It is identical with the other jar package with the original
package named mysql-connector-java-5.1.ver-bin.jar
(mysql-connector-java-commercial-5.1.ver-bin.jar for commercial
bundles), except for its more Maven-friendly file name. (Bug #27231383)
Presumably, given the closer match to Maven naming conventions, this makes it easier to install the library in local/company Maven repositories (eg if you don't want, or legally can't, use Maven Central).
But to repeat: they are the same, and you can use either one.

Where do I download sajdbc4.jar from?

I do not have SQL Anywhere installed. I have tried jconn4, and jconn3, I have also tried, jodbc4, and none of them would do what I need.
I need a pure java, type 4, jdbc driver for Sybase, and as far as I can ascertain that's sajdbc.jar. But it is nowhere to be seen. I badly need this file. Is there anyone who can tell me where I can go to download this file ?
i met the same issue these days, and i just fix this :)
First, visit this site and register : https://www.sap.com/cmp/syb/crm-xu15-int-asewindm/index.html
than u can download "ASE_Suite.winx64.zip"
open this zip file and you can see the view like this:
and than click "setupConsole.exe", you can see:
select custom , and you may select jconnect4, like this:
At the end, you can find jconnect at the place
hope this would help:))
Quoting the SQL Anywhere JDBC drivers documentation:
The Java component of the SQL Anywhere JDBC 4.0 driver is included in the sajdbc4.jar file installed into the Java subdirectory of your SQL Anywhere installation. For Windows, the native component is dbjdbc12.dll in the bin32 or bin64 subdirectory of your SQL Anywhere installation; for Unix, the native component is libdbjdbc12.so. This component must be in the system path.

oracle thin driver which jar file is used?

I have inherited a VM (linux OS) from someone. It has a java app "bob" deployed/running inside of tomcat and oracle 11.2.0 database. I wrote a simple db connection in beanshell (lightweight of java) as following example and it executed fine however a question came to my mind.
Connection con = DriverManager.getConnection("jdbc:oracle:thin:hostname:1521:sidname","username","password");
I noticed that ojdbc14.jar found /somepath/tomcat/webapps/bob/WEB-INF/lib/ojdbc14.jar AND from oracle installation /somepath/oracle/product/11.2.0/xe/jdbc/lib/{ojdbc5.jar,ojdbc6_g.jar,ojdbc6.jar} three ojdbc jar files found.
Which jar file in this case thin driver used in order to make database connection and successfully run sql query statement?
You should get rid of ojdbc14.jar and jdbc5.jar. The first one is intended for Java 1.4, the second one is intended for Java 5 (unless you actually use these outdated, non-supported Java versions).
If you are using Java7 then you should use ojdbc7.jar. If you are still using the (un-supported) Java 6, you should use ojdbc6.jar.
Note that the number in the file name only denotes the Java version, not the driver's version. To get that you would need to look at the MANIFEST.MF or use DatabaseMetaData.getDriverVersion()
Regarding the class loading in Tomcat:
Tomcat loads classes from either $CATALINA_HOME/lib, $CATALINA_HOME/lib/ext or in one of the deployed webbaps in the WEB-INF/lib directory.
So in your case, the outdated, obsolete /somepath/tomcat/webapps/bob/WEB-INF/lib/ojdbc14.jar is being used.
You should replace with an up-to-date version.

Matlab and JDDE

Update: The problem was solved with the help of MathWorks. I've published the answer below.
I need to control a program (Zemax) from Matlab. Unfortunately, Zemax only supports DDE for such control, which Matlab does not support any more. It works, but stops working on 64 bit platform after a few (presumable 63) DDE calls.
I wonder if there are working solutions. I could probably program a DLL with correct DDE support and then use DDE in Matlab via this DLL. This is a major effort for me. A more suitable solution would be to use Java DDE methods. Following another post here, I've discovered the JDDE library. However I cannot make it work: Even if I am in the directory with the DLL and JAR files, executing
import pretty-tools.JDDE-2.0.3.*
works fine but calling
a = com.pretty_tools.dde.client.DDEClientConversation()
afterwards (as done here) results in
Undefined variable "com" or class "com.pretty_tools.dde.client.DDEClientConversation".
I have very limited writing privileges on my PC, so I have added the javaclasspath.txt file with the jar/dll location to the directory indicated by prefdir. The file looks like this:
C:\Users\xxxxxxxx\Documents\matlab toolbox\jdde\pretty-tools-JDDE-2.0.3.jar
Calling javaclasspath shows a long listing with the last lines being:
...
C:\Program Files\MATLAB\R2012b\java\jarext\webservices\ws_client_core\mw-service-client-core.jar
C:\Users\kkarapet\Documents\matlab toolbox\jdde\pretty-tools-JDDE-2.0.3.jar
DYNAMIC JAVA PATH
<empty>
So path seems to be set correctly. What am I doing wrong?
With the help of MathWorks support, I've found the answer. Here is how to make JDDE work with Matlab 2012b, without admin privileges:
Download and unpack JDDE files (DLLs and JAR) into some folder. Let's say it's $path-to-jdde$\.
In Matlab, type prefdir. Open the resulting directory and create two files there, javaclasspath.txt and javalibrarypath.txt.
In javaclasspath.txt, add $path-to-jdde$\pretty-tools-JDDE-2.0.3.jar.
In javalibrarypath.txt, add $path-to-jdde$\.
Restart Matlab.
Now call ddeConv = com.pretty_tools.dde.client.DDEClientConversation; and start using the created object as described in JavaDoc. E.g. to connect to Zemax, run Zemax and then in call ddeConv.connect('Zemax', 'abc').
Step 2 above can only be done starting Matlab version R2012b. With an older version, if you have the write rights on the Matlab installation directory, you should be able to replace step 2 by editing the files librarypath.txt and classpath.txt in $MATLABROOT$\toolbox\local. I could not verify it so if you confirm it please let me know in the comment below.

Categories