-->
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.  [ 1 post ] 
Author Message
 Post subject: MSAccess Queries
PostPosted: Tue Dec 01, 2009 8:04 am 
Newbie

Joined: Tue Dec 01, 2009 7:51 am
Posts: 1
I have an Access Database. My connection is well established, but I have troubles using the following code:

Code:
this.setFORMULARNAME(fensterName);
this.setUSERNAME(userName);
Session sess=this.datenbank.databaseOpen();
           
Query test=sess.createQuery("SELECT USERNAME FROM SpeicherTabelle");
List abfrage=test.list(); //here happens the exception


Here is the exception:
Code:
01.12.2009 11:37:18 org.hibernate.jdbc.AbstractBatcher closeQueryStatement
WARNUNG: exception clearing maxRows/queryTimeout
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]Optional feature not implemented
        at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6958)
        at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7115)
        at sun.jdbc.odbc.JdbcOdbc.SQLGetStmtOption(JdbcOdbc.java:4417)
        at sun.jdbc.odbc.JdbcOdbcStatement.getStmtOption(JdbcOdbcStatement.java:1208)
        at sun.jdbc.odbc.JdbcOdbcStatement.getQueryTimeout(JdbcOdbcStatement.java:697)
        at org.hibernate.jdbc.AbstractBatcher.closeQueryStatement(AbstractBatcher.java:277)
        at org.hibernate.jdbc.AbstractBatcher.closeQueryStatement(AbstractBatcher.java:212)
        at org.hibernate.loader.Loader.doQuery(Loader.java:726)
        at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
        at org.hibernate.loader.Loader.doList(Loader.java:2220)
        at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
        at org.hibernate.loader.Loader.list(Loader.java:2099)
        at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:378)
        at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
        at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
        at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
        at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
        at reportingneu.tabellen.java.speichertabelle.SpeicherTabelle.speichereFormular(SpeicherTabelle.java:137)
        at reportingneu.frontend.desktop.hilfe.JDatawarehouseXML.CMD_WAREHOUSEXML_SAVEMousePressed(JDatawarehouseXML.java:149)
        at reportingneu.frontend.desktop.hilfe.JDatawarehouseXML.access$100(JDatawarehouseXM


Here is my Dialectfile:
Code:
import java.sql.Types;
import org.hibernate.Hibernate;
import org.hibernate.cfg.Environment;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.function.NoArgSQLFunction;
import org.hibernate.dialect.function.StandardSQLFunction;

/**
*
*/
public class MSAccessDialect4 extends Dialect {
    public MSAccessDialect4() {
        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" );
        registerColumnType( Types.BLOB, "MEMO" ); // so that's 65,535 characters in Access
        registerColumnType( Types.CLOB, "MEMO" ); // so that's 2.14 GB in Access

        registerFunction( "asc",        new StandardSQLFunction("asc",      Hibernate.INTEGER   ) ); // SQL Server: ascii(x)
        registerFunction( "char",       new StandardSQLFunction("char",     Hibernate.CHARACTER ) ); // SQL Server: chr(x)
        registerFunction( "len",        new StandardSQLFunction("len",      Hibernate.LONG      ) ); // SQL Server: datalength(x)
        registerFunction( "lcase$",     new StandardSQLFunction("lcase$"                        ) ); // SQL Server: lower(x)
        registerFunction( "ucase$",     new StandardSQLFunction("ucase$"                        ) ); // SQL Server: upper(x)
        registerFunction( "str$",       new StandardSQLFunction("str$",     Hibernate.STRING    ) ); // SQL Server: str(x)
        registerFunction( "ltrim$",     new StandardSQLFunction("ltrim$"                        ) ); // SQL Server: ltrim(x)
        registerFunction( "rtrim$",     new StandardSQLFunction("rtrim$"                        ) ); // SQL Server: rtrim(x)
        registerFunction( "right$",     new StandardSQLFunction("right$"                        ) ); // SQL Server: right(x,y)
        registerFunction( "mid$",       new StandardSQLFunction("mid$"                          ) ); // SQL Server: substring(x,y,z)
        registerFunction( "day",        new StandardSQLFunction("day",      Hibernate.INTEGER   ) );
        registerFunction( "month",      new StandardSQLFunction("month",    Hibernate.INTEGER   ) );
        registerFunction( "year",       new StandardSQLFunction("year",     Hibernate.INTEGER   ) );
        registerFunction( "datename",   new StandardSQLFunction("datename", Hibernate.STRING    ) );
        registerFunction( "abs",        new StandardSQLFunction("abs"                           ) );
        registerFunction( "sign",       new StandardSQLFunction("sign",     Hibernate.INTEGER   ) );
        registerFunction( "acos",       new StandardSQLFunction("acos",     Hibernate.DOUBLE    ) );
        registerFunction( "asin",       new StandardSQLFunction("asin",     Hibernate.DOUBLE    ) );
        registerFunction( "atan",       new StandardSQLFunction("atan",     Hibernate.DOUBLE    ) );
        registerFunction( "cos",        new StandardSQLFunction("cos",      Hibernate.DOUBLE    ) );
        registerFunction( "cot",        new StandardSQLFunction("cot",      Hibernate.DOUBLE    ) );
        registerFunction( "exp",        new StandardSQLFunction("exp",      Hibernate.DOUBLE    ) );
        registerFunction( "log",        new StandardSQLFunction("log",      Hibernate.DOUBLE    ) );
        registerFunction( "log10",      new StandardSQLFunction("log10",    Hibernate.DOUBLE    ) );
        registerFunction( "sin",        new StandardSQLFunction("sin",      Hibernate.DOUBLE    ) );
        registerFunction( "sqrt",       new StandardSQLFunction("sqrt",     Hibernate.DOUBLE    ) );
        registerFunction( "tan",        new StandardSQLFunction("tan",      Hibernate.DOUBLE    ) );
        registerFunction( "square",     new StandardSQLFunction("square"                        ) );
        registerFunction( "rand",       new StandardSQLFunction("rand",     Hibernate.FLOAT     ) );
        registerFunction("radians",     new StandardSQLFunction("radians",  Hibernate.DOUBLE    ) );
        registerFunction("degrees",     new StandardSQLFunction("degrees",  Hibernate.DOUBLE    ) );
        registerFunction( "round",      new StandardSQLFunction("round"                         ) );
        registerFunction( "ceiling",    new StandardSQLFunction("ceiling"                       ) );
        registerFunction( "floor",      new StandardSQLFunction("floor"                         ) );
       
        registerFunction( "getdate",    new NoArgSQLFunction("getdate",     Hibernate.TIMESTAMP ) );
        registerFunction( "getutcdate", new NoArgSQLFunction("getutcdate",  Hibernate.TIMESTAMP ) );
        registerFunction( "pi",         new NoArgSQLFunction("pi",          Hibernate.DOUBLE    ) );
        //getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE,NO_BATCH);
        getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, this.NO_BATCH);
        //getDefaultProperties().setProperty(Environment.STATEMENT_FETCH_SIZE, "0");
        //Environment.STATEMENT_FETCH_SIZE
    }

    @Override
    public boolean supportsIdentityColumns() {
        return true;
    }

    @Override
    public String getIdentityColumnString() {
        return "IDENTITY NOT NULL";
    }

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

    @Override
    public boolean hasDataTypeInIdentityColumn() {
        return false;
    }


    public boolean supportsForUpdate() {
            return false;
    }

    @Override
    public String getForUpdateString() {
            return "";
    }



    @Override
    public String getNoColumnsInsertString() {
        return "DEFAULT VALUES";
    }

    @Override
    public boolean supportsParametersInInsertSelect() {
   return false;
    }


    @Override
    public String getAddColumnString() {
            return "add";
    }
    @Override
    public String getNullColumnString() {
            return " null";
    }

    @Override
    public boolean qualifyIndexName() {
            return false;
    }


}


And here is my configuration file:

Code:
<?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="connection.url">jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};ExtendedAnsiSQL=1;DBQ=</property>
    <property name="connection.driver_class">sun.jdbc.odbc.JdbcOdbcDriver</property>
    <property name="dialect">reportingneu.datenbank.access.dialects.MSAccessDialect4</property>
    <property name="connection.username"></property>
    <property name="connection.password"/>
    <property name="connection.autocommit">true</property>
   
    <property name="show_sql">true</property>
    <property name="hibernate.generate_statistics">true</property>
    <property name="hibernate.use_sql_comments">false</property>
    <property name="hibernate.hbm2ddl.auto"></property>
   
    <!--<property name="hibernate.connection.charSet">cp936</property>-->
    <property name="hibernate.jdbc.fetch_size">0</property>
    <property name="hibernate.jdbc.batch_size">0</property>
    <property name="hibernate.jdbc.fetch_size">0</property>
    <!--<property name="hibernate.cache.use_query_cache">false</property>
    <property name="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</property>-->


   
    <property name="org.hibernate.SQL">true</property>
    <property name="org.hibernate.type">true</property>
    <property name="org.hibernate.tool.hbm2ddl">true</property>
    <property name="org.hibernate.pretty">true</property>
    <property name="org.hibernate.cache">true</property>
    <property name="org.hibernate.transaction">true</property>
    <property name="org.hibernate.jdbc">true</property>
    <property name="org.hibernate.hql.ast.AST">true</property>
    <property name="org.hibernate.secure">true</property>
    <property name="org.hibernate">true</property>
    <property name="log4j.logger.org.hibernate">ERROR</property>
    <property name="log4j.logger.org.hibernate.type">ERROR</property>
    <property name="log4j.logger.org.hibernate.SQL">DEBUG</property>

    <mapping resource="reportingNeu/tabellen/xml/FehlerTabelle.hbm.xml"/>
    <mapping resource="reportingNeu/tabellen/xml/speichertabelle/SpeicherTabelle.hbm.xml"/>
  </session-factory>
</hibernate-configuration>


Here is the xml file from the table:
Code:
<?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE hibernate-mapping PUBLIC ""
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">


    <hibernate-mapping auto-import="true" default-lazy="false">
        <class name="reportingneu.tabellen.java.speichertabelle.SpeicherTabelle" table="TBL_SAVE">

            <id name="SAVEID"
                type="java.lang.Integer"
                column="SAVEID"
                >
                <generator class="identity"/>
            </id>

            <property
                name="USERNAME"
                type="java.lang.String"
                column="USERNAME"
                length="255"
            />

            <property
                name="ATTRIBUTNAME"
                type="java.lang.String"
                column="ATTRIBUTNAME"
                length="255"
            />

            <property
                name="ATTRIBUTWERT"
                type="java.lang.String"
                column="ATTRIBUTWERT"
                length="255"
            />

            <property
                name="ATTRIBUTSPEICHERWERT"
                type="java.lang.String"
                column="ATTRIBUTSPEICHERWERT"
                length="255"
            />

            <property
                name="FORMULARNAME"
                type="java.lang.String"
                column="FORMULARNAME"
                not-null="true"
                length="255"
            />

        </class>
    </hibernate-mapping>


I really tried a lot to keep it running, but it will not work. Can you tell me what I am doing wrong?


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

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.