where is org.apache.derby.jdbc.ClientDriver? - java

I downloaded the jar of Core Apache Derby database engine, which also includes the embedded JDBC driver (10.9.1.0). But that jar doesn't include the .class file of ClientDriver in the jdbc package. Why is that ? Where can i find this class file ? I need this file to connect to derby database from tomcat as the server.
Please provide the download link of the complete jar so that i get the required .class file.

OK: have you looked on the Apache Derby page:
http://db.apache.org/derby/releases/release-10.9.1.0.cgi
Download db-derby-10.9.1.0-bin.zip
It contains many files, including derby.jar and derbyclient.jar (along with much documentation).
derbyclient.jar contains our friend org.apache.derby.jdbc.ClientDriver.class

#Paulsm4 is correct.
But please keep in mind also that:
org.apache.derby.jdbc.ClientDriver
which can be found inside derbyclient.jar is enough to just obtain connection to the running Derby DB server.
But if you would like to create embedded (in memory) database when obtaining connection, then you have to use different jdbc driver:
org.apache.derby.jdbc.EmbeddedDriver
which can be found inside derby.jar. Moreover, additional parameter create=true has to be passed. For example:
<property name="javax.persistence.jdbc.url" value="jdbc:derby:myApp;databaseName=myApp;create=true" />
Hope it helps somebody.

Related

where are Oracle's DMS class files?

I'm running a JBoss server (inside Eclipse), with some Hibernate mixed in. I installed Oracle's ojdbc drivers from here:
Oracle Database 11g Release 2 JDBC Drivers
I specifically downloaded the file: ojdbc6dms_g.jar, which according to the site contains instrumentation to support DMS. However when I startup my AS server, I get the following:
Caused by: java.lang.ClassNotFoundException: oracle.dms.console.DMSConsole from [Module
"com.oracle:main" from local module loader #485fcf29 (roots: /usr/local/jboss-7.1.1-
final/modules)]
when the server is trying to get a new hibernate ejb exception.
I checked Oracle's jar file and sure enough it doesn't contain the class oracle.dms.console.DMSConsole, although from the notes on Oracle's site about the jar file, it seems like the jar file should contain the DMS classes.
Can anyone point me to the correct jar file? And when I do get the right file, where should this file be installed to, particularly with regards to Eclipse and JBoss?
Update: Just found another question asking the same thing here on SO.
The missing classes are indeed in dms.jar. But as I've seen asked elsewhere finding the dms.jar file is not easy. You won't find dms.jar at Oracle Database 11g Release 2 JDBC Drivers because as noted by Oracle: dms.jar is not shipped as part of the RDBMS product. It is only available as part of the Oracle Application Server product.
I hopped onto our server and grabbed the jar file from our Oracle installation directory. We have 11g installed. With 11g you should be able to find the file here:
$ORACLE_HOME/oc4j/lib/dms.jar
I got the same error for different reason and yes it was due to missing dms.jar file. I just had to find where dms.jar file was on our Oracle Application server (Release 12.2.3) and assigned it to the CLASSPATH. And it worked. Thanks for the pointing to the missing .jar file.
Out .jar file was in $ORACLE_HOME/lib/ folder. Changed the path value as :
CLASSPATH=$CLASSPATH:$ORACLE_HOME/lib/dms.jar and it started working.
Fyi..if it helps anyone i was trying to load BI/XML publisher DATA TEMPLATE using XDOLoader utility when i got this error.
-ppemavath
i too face this problem but when i removed all database related jars and added ojdbc6 (or ojdbc7) jar then application working fine. more details please see below link.
https://community.oracle.com/thread/2388722

Making BIRT see sqljdbc_auth.dll when doing integrated security database connection

I am using BIRT that needs to connect to a database using integrated security via a jdbc driver. When my .jar file (imported into BIRT) tries to connect to the MSSQL database, I get the following error: The driver is not configured for an integrated authentication...
My conclusion is that BIRT dimply does not see the sqljdbc_auth.dll file.
How do I make BIRT see sqljdbc_auth.dll library, other than just putting it into the BIRT's root folder? Can I issue -djava.library.path = .... somewhere within BIRT RCP?
Thanks!!
Can you post the eclipse.ini? Any vm arguments should be put after the -vmargs option on a new line. See http://wiki.eclipse.org/Eclipse.ini.

Is there any way to save embbeded apache derby database files in jar

In my project when i clicked the jar file it extracts embedded database files to near it self.
Is there any way to make them stay in the jar file?
You can package a read-only Derby database into one of the jar files in your classpath, and access it using a different form of the connection URL. See: http://db.apache.org/derby/docs/10.8/devguide/cdevdvlp24155.html and http://db.apache.org/derby/docs/10.8/devguide/cdevdeploy11201.html#cdevdeploy11201
Sure it's possible, you can put your DB image into any JAR's classpath and access it using:
Class.getResourceAsStream()

Jar file dependencies in Java 1.4

I'm working on a small Java project that now connects to a MS SQL Server 2000 database, but will be shortly connecting to MS SQL Server 2005 database. I'm creating a single jar for ease of deployment. I was trying to set it up so I could just change a configuration file and change drivers (as I would in .NET). However, because of the limitations of Java's Jar embedded classpath, and the lack of the wildcard character on the embedded classpath(1). Is there any way to get around this problem without referencing every driver jar explicitly?
If I have to do that I'll have to recompile every time the database changes ...
(1): However, class path wildcards are not honored in the Class-Path jar-manifest header.
Generally, you can modify the classpath at runtime. Approaches like this are the general way to deal with "plugin" type jars in Java (very similar requirements to your case).
You could include the information about which driver to use in e.g. a config file. Or in the manifest of the JAR file itself. Simply include all JAR files when starting your application but load the driver’s name from the configuration.
I would say that it is not the Java way (as in the standard practice) to include third party code in the same Jar as you are deploying. However a jar is just a zip file, so in most cases (excepting some fancy stuff going on in the manifests) you can combine them, if you need to.
That being said, you can include in your jar file a classpath reference to all potential JDBC driver jars, or simply call the JDBC driver jar the right way. Then have a configuration file in the same directory (be sure to include . in your JAR's classpath) and then read the driver name from that, and use Class.forName() to load the driver.
You can do fancier things (like find the right jar at runtime and dynamically load it even though it wasn't on the classpath) but those things are a bit complicated, so something simple like the above should work.
You should never have to recompile. You aren't really doing JDBC right if you have to recompile when you change drivers.
You have to seperate the driver jar file and the actual name of the JDBC driver for the particular provider.
I would really encourage to not to include jdbc driver jars in your own jar.
Just at them to the path at runtime.
Similarly you can get the name of the JDBC driver manager from the system properties during runtime, or even a config file.
So running app like this:
java -jar myapp.jar -cp sqlserver.jar -DdriverManager=com.microsoft.sqlserver.jdbc.SQLServerDriver -DdbUrl=jdbc:some:url
and in your application, do something like this (I leave out exception handling):
Class.forName(System.getProperty("driverManager"));
Connection conn = DriverManager.getConnection(System.getProperty("dbUrl"))
;
This way you can change drivers simply by adding appropriate jar file to the classpath and changing the driverManager and dbUrl properties. This way you don't have to recompile to support new drivers.
That's the simplest solution that I can think of.

No suitable MySQL driver found for JBoss application

I am new to creating Java web applications and came across this problem when trying to interact with my database (called ccdb) through my application:
java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost/ccdb/
My application runs on JBoss and uses Hibernate to interact with the MySQL database. I have the MySQL Driver in lib\mysql-connector-java-5.1.6-bin.jar of my project and I have the .jar configured in Eclipse as a "Java EE Module Dependency" so that it gets copied over to web-inf\lib\ when I deploy it to JBoss through Eclipse. I double checked and the driver is definitely in the .war file with the project, so it should be findable, right?
My hibernate.cfg.xml contains this line which should point hibernate to the driver.
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
Does anyone know what I need to do to get this to work? Do I have to configure the MySQL database as a JBoss datasource for it to work?
Thanks in advance.
Edit: kauppi's solution works, but I would prefer to have it in lib\ with the other jars, and I'm really curious as to why it won't work that way. Any ideas...?
There might be a better way to do it but I have usually copied the MySQL connector JAR to jboss\server\default\lib (assuming that you are using the default config).
putting external libraries in the lib folder is a bad practice.
You need to edit the file:
server/${servername}/conf/jboss-service.xml
and add
<classpath codebase="${jboss.server.lib.url:lib}ext" archives="*"/>
rigth after
<classpath codebase="${jboss.server.lib.url:lib}" archives="*"/>
then create a directory named:
server/${servername}/lib/ext
and drop your external jars in there.

Categories

Resources