VP & unit test

Hi,
I’m trying to write some units test, so I decide to use different database.
I saw that PersistentManager implementation exposes setJDBCConnectionSetting method. So I wrote the following code:

  
        JDBCConnectionSetting settings = new JDBCConnectionSetting();
        settings.setDriver(org.hsqldb.jdbcDriver.class.getName());
        settings.setConnectionURL("jdbc:hsqldb:mem:ProductDAOTest");
        settings.setUserName("sa");
        settings.setDialect(HSQLDialect.class.getName());
        GestionePersistentManager.setJDBCConnectionSetting(settings);
 

Simple, but when I launch debug it alway throws new ClassNotFoundException. The message is: JDBC Driver class not found.
But I’m absolutely sure that the driver file is correctly in path.

Thanks in advance.

Maurizio

Hi Maurizio,

Thanks for your post.

I’m absolutely sure that the driver file is correctly in path
May I know how did you configure the connection, and how do you make sure that the driver file is in correct path?

Best regards,
Lilian Wong

Hi Lilian,
thanks for you answer…

[quote=LilianWong]Hi Maurizio,

Thanks for your post.

I’m absolutely sure that the driver file is correctly in path
May I know how did you configure the connection, and how do you make sure that the driver file is in correct path?
[/quote]
About the path… I include hsqldb.jar via Intellij Idea. It launch class file with java -classpath /usr/share/java/hsqldb.jar …
Here Connection configuration is:

 
...
<property name="dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
		<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
		<property name="connection.url">jdbc:mysql://localhost/gestione2?zeroDateTimeBehavior=convertToNull</property>
		<property name="connection.username">USERNAME</property>
		<property name="connection.password">PASSWORD</property>
		<property name="hibernate.hbm2ddl.auto">create</property>
        <property name="show_sql">false</property>
		<property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property>
        <property name="transaction.auto_close_session">true</property>
        <property name="transaction.flush_before_completion">true</property>
...
 

Thanks
Maurizio

Hello Maurizio,

Can you send me the complete source file which you experienced problem to have a look?

Best regards,
Rain