No suitable MySQL driver found for JBoss application - java

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.

Related

Update postgres database properties in activiti source code

I have downloaded the latest activiti source code(5.21.0),by default the activiti will point to h2 database and I want to change that to postgres.I made changes in db.properties file in-order to point my database.When I restart the activiti-explorer still it's pointing to h2 db. I have added the dependency of postgres in activiti POM file as well. My db.properties file is as follow:
db=postgres
jdbc.driver=org.postgresql.Driver
jdbc.url=jdbc:postgresql://localhost:5432/activitiDB
jdbc.username=postgres
jdbc.password=password
Can anyone help me to sort it out.
Sagari , did you try modifying the activiti engine as well. There is a configuration file for the same which contains the datasource properties. This can be used as the alternative to the property file approach.
It is elaborated here :
http://www.activiti.org/userguide/
(Database configuration)
Also could you try mvn clean and try running again. May be it will help
How are you running Explorer? Did you do a build of the webapp to get the war.
If so, changing the db.properties is all that's needed indeed. Where did you put that file?
Also, there's no need to clone the source code, you can download the latest zip file from http://activiti.org/download.html, it contains the explorer war file already.

Cannot load net.sourceforge.jtds.jdbc.Driver in Tomcat

I see there are other similar questions, but none of them cover my exact situation.
I'm migrating an Eclipse based web service from FreeBSD 9.2 and Tomcat7 over to FreeBSD 10.0 and Tomcat8. I've deployed my .war on the new server and it runs, right up until it has to do a SQL access, where it fails with "cannot load net.sourceforge.jtds.jdbc.Driver". I'm not sure what's missing. We don't load a driver in lib, it's all bundled into the one .war file (which works fine on the old machine). I've searched the tomcat config files to see if there's any pointers that need to be set, but I'm coming up empty.
Download the jTDS driver from here. Copy it into the Tomcats lib folder. Are you sure you are not using JNDI to retreive the datasource? If thats not the case, its better to include app specific jars in your project and not on the server, to avoid version conflicts with other projects.
Download ojdbc6 or ojdbc14 (which one usefull for Tomcat8)
copy to apache-tomcat-(version) >> lib file.
And in eclipse add ojdbc in Build Path >> order & export.

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

Mysql ClusterJ Plug-in

Mysql cluster comes with jars for clusterj. I downloaded Mysql Cluster 7.2.7. In shared/java folder,clusterj-7.2.7.jar,clusterj-api-7.2.7.jar,etc. exist. But when I add them to my project class path and write my first Java application that uses clusterj, some classes like SessionFactory,Session,ClusterJHelper is not included in the available jars. In another words, in none of the my jars includes these classes and then I cannot import. Why ?
You are really need to download the latest MySQL Cluster 7.2. SessionFactory, Session, and ClusterJHelper included in
clusterj-7.2.10.jar
clusterj-api-7.2.10.jar
clusterjpa-7.2.10.jar

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

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.

Categories

Resources