I getting an error when running my program. the error is: org.hibernate.HibernateException: JDBC Driver class not found: com.mysql.jdbc.Driver.
The driver is there...I am not sure what it causing this. Any suggestions?
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/registrar</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">root</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<mapping resource="com/ths/entity/Course.hbm.xml"/>
<mapping resource="com/ths/entity/Student.hbm.xml"/>
<mapping resource="com/ths/entity/Enrollment.hbm.xml"/>
</session-factory>
</hibernate-configuration>
The driver is there...I am not sure what it causing this.
The driver is not there. The error is simple: the Java VM couldn't find your driver. So, double-check the classpath. If you are deploying a web-application, make sure your driver is in the server's lib, and not in WEB-INF/lib.
You may have that jar in project but class loader is unable to find that as class loader does not check each and every folder of project. If it is a web application then you need to put jar file in WEB-INF/LIB.
If it is a standalone application then you need to add jar file in build path.
you can check class path during run time to see whether folder (where jar exist) is considered in class path or not.
I am not sure what was causing this. I was trying this on my work computer. I tried it at home and it worked fine. Must just be a setting.
Related
I know thats a known problem and i made my research but still couldnt find a proper answer and what to do, so my last hope is here. The problem is, when i use phpAdmin i can connect and create my tables in m database. But when i run hibernates connection wizard, after entering the connection properties, if i press the test connection it gives me this error :
"Timeout expired. IDE unable to establish connection. Check your proxy settings or try again later. The server may be unavailable at the moment. You may also want to make sure that your firewall is not blocking network traffic."
My hibernate.cfg.xml looks like this
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://127.11.83.2:3306</property>
<property name="hibernate.connection.username">admin1s6nbcM</property>
<property name="hibernate.connection.password">*******</property>
</session-factory>
</hibernate-configuration>
I m suspecting that there is something wrong with MySQL Java Connector library ;
dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.30</version>
</dependency>
because i get this warning when i build my application:
Some problems were encountered while building the effective model for cardsystelefonbuch:cardsystelefonbuch:war:1.0
'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: mysql:mysql-connector-java:jar -> version 5.1.25 vs 5.1.30 # line 83, column 13
It is highly recommended to fix these problems because they threaten the stability of your build.
For this reason, future Maven versions might no longer support building such malformed projects.
Any ideas would be greatly appreciated !
I have a web application and I´m trying to get Hibernate working.
As soon as I call my webservice, which uses Hibernate, I´m getting the error
org.hibernate.service.classloading.spi.ClassLoadingException: Specified JDBC Driver could not be loaded
I´ve read some posts on SO, where the solution was to add the driver to the classpath.
What I first did is, I´ve added the dependency to my pom.xml, but afterwards it did not download any libs, so I downloaded it manually with maven.
Now I´ve "mysql-connector-java-5.1.31.jar" in my libs and added the stuff to my project.
But it had no effect.
Afterwards I´ve copied the lib to my TOMCAT/libs folder which also had no effect.
Why can´t the driver be loaded and how can I fix it?
My hibernate.cfg.xml:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.url">jdbc:mysql://localhost:3306/myproject</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.username">hibernate</property>
<property name="connection.password">hibernate</property>
<mapping class="database.DevicetableEntity"/>
<!-- DB schema will be updated if needed -->
<!-- <property name="hbm2ddl.auto">update</property> -->
</session-factory>
How do I see MySql connection URL from openshift? I need it to use it in hibernate.cfg.xml
When I log onto my account online I only see the username and password.
On open shift the database is already available in JNDI. It's name is jdbc/MySQLDS.
To use this 'datasource' in hibernate, your hibernate.cfg.xml should look something like this:
<!-- Database connection settings -->
<property name="hibernate.connection.datasource">java:comp/env/jdbc/MySQLDB</property>
<!-- SQL dialect -->
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<!-- Mapped annotated entity-->
<mapping class="org.hibernate.tutorial.domain.Event"/>
</session-factory>
To help you even mote please tell us if you are using JbossEWS 1.0, 2.0, JBoss AS6, JBoss EAP. Is your app scale, etcetera.
I have an web application in struts 1.3 which contain hibernate as ORM and spring as contextloaded AOP or as it is in general use.
I'm trying to deploy it in tomcat 6.0 server. earlier it was connected to mysql and it was working fine but now I want to connect it with MS Sql server 2008 so I downloaded "sqljdbc" and "sqljdbc4" jar and placed it into "C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\web1\WEB-INF\lib" location of my system. I have java 7 installed in my system.when I trying to run then its giving exception :
org.apache.jasper.JasperException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/applicationContext-hibernate.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyAccessExceptionsException: PropertyAccessExceptionsException (1 errors); nested propertyAccessExceptions are: [org.springframework.beans.MethodInvocationException: Property 'driverClassName' threw exception; nested exception is org.springframework.jdbc.CannotGetJdbcConnectionException: Could not load JDBC driver class ["com.microsoft.sqlserver.jdbc.SQLServerDriver";]; nested exception is java.lang.ClassNotFoundException: "com/microsoft/sqlserver/jdbc/SQLServerDriver";]
My jdbc property file entry is :
jdbc.driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver";
jdbc.url="jdbc:sqlserver://localhost:1433/databaseName=DB_1"
jdbc.username="dipak";
jdbc.password="";
hibernate.dialect=org.hibernate.dialect.SQLServer2008Dialect
ApplicationContext-Hibernate.xml
entry is :
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${jdbc.driverClassName}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>
Please help me to solve this problem, I Google a lot and tried many solutions but not get success yet, So any help would be much appreciated.
If you need any other/more information then please let me know.
Thanks,
-Dipak
Wrong spot for that JAR. Tomcat 6 and higher expects to find it in the Tomcat server /lib, not your application WEB-INF/lib. Move it and you'll see better results.
Make sure that your URL syntax is correct:
http://msdn.microsoft.com/en-us/library/ms378428(v=sql.90).aspx
I am a beginer with visual studio 2008 (C#), mysql and NHibernate.
I have problems with mysql connector as I don't know how to add reference to it.
In my project I have:
/lib/mysql-connector-net-6.1.4-src/
(downloaded from http://dev.mysql.com/downloads/mirror.php?id=387799#mirrors)
Now I right click on my project -> addReference -> browse -> What now?
Should I also edit my hibernate configuration?
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="connection.driver_class">NHibernate.Driver.MySqlDataDriver</property>
<property name="connection.connection_string">Server=localhost;database=Pets;Database=pets,User ID=root,Password=;</property>
<property name="dialect">NHibernate.Dialect.MySQL5Dialect</property>
<property name="proxyfactory.factory_class"> NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu </property>
<property name="show_sql">false</property>
</session-factory>
</hibernate-configuration>
Thanks
You need to add a reference to the MySQL connector DLL that corresponds to the version of .NET you are targeting.
From the link provided, it seems like you downloaded the source code for the MySQL connector, so you'll either need to build this code and take the desired DLL out of the /bin folder afterwards or download a full installer (which will include the binaries) from the second link here:
http://dev.mysql.com/downloads/connector/net/6.1.html
Once you add this DLL to your project, you'll need to edit that NHibernate configuration to update the "connection.connection_string" property with the connection string for your database.
Hope this helps. There is some more documentation available here:
http://dev.mysql.com/doc/refman/5.1/en/connector-net.html