-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 
Author Message
 Post subject: Hibernate configuration with MS access
PostPosted: Mon Jan 02, 2006 2:22 am 
Newbie

Joined: Mon Jan 02, 2006 2:07 am
Posts: 1
hello everyone,

I am trying to use Hibernate With MS Access database.Any one can write me
that how I can use MS access with hibernate.I am pasting the config file code
for oracle ,suggest me what should be the changes to work with MS Access instead of Oracle.here is config code For Oracle....

<hibernate-configuration>
<session-factory>
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="connection.url">jdbc:oracle:thin:@Server:1521:daffodil</property>
<property name="connection.username">vidushialpha</property>
<property name="connection.password">vidushialpha</property>
<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
<property name="hibernate.c3p0.min_size">1</property>
<property name="hibernate.c3p0.max_size">3</property>

<!-- Fetch level-->
<property name="hibernate.max_fetch_depth">3</property>


<!-- other hibernate properties -->
<!--


<property name="hbm2ddl.auto">update</property>-->

<property name="hibernate.show_sql">true</property>


</session-factory>
</hibernate-configuration>

PLZ write me what sould be the changes in this config file to work with MS access if possible.

any seggestion will be highly appreciable

saleem khan


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 02, 2006 5:29 am 
Regular
Regular

Joined: Wed Jun 29, 2005 11:14 pm
Posts: 119
Location: København
Found this http://www.hibernate.org/361.html

Any help?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 02, 2006 5:32 am 
Regular
Regular

Joined: Wed Jun 29, 2005 11:14 pm
Posts: 119
Location: København
Ignore that, I'm working both on .net and java at the same time...


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 02, 2006 5:41 am 
Regular
Regular

Joined: Wed Jun 29, 2005 11:14 pm
Posts: 119
Location: København
So after some searching:

Access Dialect is not written - someone on the forum posted (http://forum.hibernate.org/viewtopic.ph ... ss+dialect) an example one though which follows:

Code:
/*
* Created on Sep 23, 2005
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package org.hibernate.unsupported.dialect;

import java.sql.Types;

import org.hibernate.cfg.Environment;
import org.hibernate.dialect.Dialect;

/**
* @author Suchak.Jani  w/ modifications by Eric Klimas
* This code is blatently ripped off from the Hibernate forums discussion
* on MS Access and Hibernate found here:
* <a href="http://forums.hibernate.org/viewtopic.php?p=2178009&sid=876222db25ab13214a3729dbe1e494b6">
* http://forums.hibernate.org/viewtopic.php?p=2178009&sid=876222db25ab13214a3729dbe1e494b6</a>
* <p>
* The code has been modified by Eric to:
* <ol>
* <li>Work with the current version of hibernate since Dialect.NO_BATCH no longer exists</li>
* <li>Be placed in a different package (org.hibernate.unsupported.dialect) so nobody gets the idea
* that this is actively supported by hibernate or anybody for that matter.  <b>USE AT YOUR OWN RISK...</b></li>
* </ol>
*/
public class MSAccessDialect
extends Dialect {

        public MSAccessDialect() {
                super();
                registerColumnType( Types.BIT, "BIT" );
                registerColumnType( Types.BIGINT, "INTEGER" );
                registerColumnType( Types.SMALLINT, "SMALLINT" );
                registerColumnType( Types.TINYINT, "BYTE" );
                registerColumnType( Types.INTEGER, "INTEGER" );
                registerColumnType( Types.CHAR, "VARCHAR(1)" );
                registerColumnType( Types.VARCHAR, "VARCHAR($l)" );
                registerColumnType( Types.FLOAT, "DOUBLE" );
                registerColumnType( Types.DOUBLE, "DOUBLE" );
                registerColumnType( Types.DATE, "DATETIME" );
                registerColumnType( Types.TIME, "DATETIME" );
                registerColumnType( Types.TIMESTAMP, "DATETIME" );
                registerColumnType( Types.VARBINARY, "VARBINARY($l)" );
                registerColumnType( Types.NUMERIC, "NUMERIC" );

                getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, "0");
        }

        public String getIdentityColumnString() {
                //return " counter ";
                return "not null auto_number";
        }

        public String getIdentitySelectString() {
                return "select @@IDENTITY";
        }


        /**
         * Returns for update syntax for access, which is non-existant, so I *think*
         * we return an empty string...
         * @return String an beautifully constructed empty string...
         */
        public String getForUpdateString() {
                return "";
        }
}


And then you need to use the jdbc-odbc driver

Code:
<!-- MS ACCESS -->
<property name="hibernate.dialect" value="org.hibernate.unsupported.dialect"/>
<property name="hibernate.conn.driver_class" value="sun.jdbc.odbc.JdbcOdbcDriver"/>
<property name="hibernate.conn.url" value="jdbc:odbc:;DRIVER=Microsoft Access Driver (*.mdb);DBQ=C:\hibernate_intro\accessdb.mdb"/>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 02, 2006 5:48 am 
Expert
Expert

Joined: Thu May 26, 2005 9:19 am
Posts: 262
Location: Oak Creek, WI
Hi Saleem,

The below link will tell the databases that are supported by Hibernate.

http://www.hibernate.org/260.html

NO MS ACCESS SUPPORT

_________________
RamnathN
Senior Software Engineer
http://www.linkedin.com/in/ramnathn
Don't forget to rate.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 20, 2007 9:53 am 
Beginner
Beginner

Joined: Tue Sep 16, 2003 11:26 am
Posts: 25
Location: Berlin - Germany
Read this:
http://www.hibernate.org/80.html
Quote:
Hibernate has also been tested with and is believed to be compatible with current versions of:
...
Microsoft Access version from 95, 97, 2000, XP, 2002, to 2003 (requires Dialect from HXTT)
...

HXTT is a Chinese company with offers a "Pure Java JDBC Drivers for MS Access":
http://www.hxtt.com/access.html. I will try to use this driver for an new project soon.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 20, 2007 10:06 am 
Beginner
Beginner

Joined: Tue Sep 16, 2003 11:26 am
Posts: 25
Location: Berlin - Germany
HXTT offers a Hibernate Support Package: http://www.hxtt.com/hibernate.html

An MS Access dialect for hibernate is included.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.