ManikandanBalachandran
asked on
schema does not exist - Apache derby
How do i set the default schema "APP" to the user name "sa"?, How to do it with Hibernate?
My hibernate config xml file is here
<property name="hibernate.connection .driver_cl ass">org.a pache.derb y.jdbc.Cli entDriver< /property>
<property name="hibernate.connection .url">jdbc :derby://l ocalhost:1 527/AutoDB ;</propert y>
<property name="hibernate.dialect">o rg.hiberna te.dialect .DerbyDial ect</prope rty>
<property name="hibernate.connection .username" >sa</prope rty>
<property name="hibernate.connection .password" >hidepassw ord</prope rty>
<!-- Specific the default schema to connect -->
<property name="hibernate.default_sc hema">APP< /property>
<!-- Specific the default schema to connect -->
<property name="hibernate.default_ca talog">APP </property >
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size ">300</pro perty>
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_cont ext_class" >thread</p roperty>
<!-- Disable the second-level cache -->
<property name="cache.provider_class ">org.hibe rnate.cach e.NoCacheP rovider</p roperty>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">false</pro perty>
<!-- Drop and re-create the database schema on startup -->
<property name="hbm2ddl.auto">update </property >
My hibernate config xml file is here
<property name="hibernate.connection
<property name="hibernate.connection
<property name="hibernate.dialect">o
<property name="hibernate.connection
<property name="hibernate.connection
<!-- Specific the default schema to connect -->
<property name="hibernate.default_sc
<!-- Specific the default schema to connect -->
<property name="hibernate.default_ca
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_cont
<!-- Disable the second-level cache -->
<property name="cache.provider_class
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">false</pro
<!-- Drop and re-create the database schema on startup -->
<property name="hbm2ddl.auto">update
when you defind the sessionFactory property that time you can specify the default_shema then it will apply all calss mapping files !!
ASKER
Yes i did that but still getting the same error "schema does not exist". Looks like default_schema is ment for Oracle or some other DBs not for Derby, Any other solutions please?
r u using hbm file ??
yes means set shema there ! and remove from your xml file and check ??
yes means set shema there ! and remove from your xml file and check ??
ASKER
Please give a sample hbm file for setting schema
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
<class name="com.tts.papa.javabea ns.DocAppr ovalDetail s" table="DOC_APPROVAL_DETAIL S" shema ="check">
@dravidnsr, with derby there is no notion of a schema that you can specify in a HBM file. The driver will always connect to the default schema only as per derby.
Is it ... I didnt work in derby . i thought its apacy product so we can use hbm ...
Thanks ...
Thanks ...
The current schema for any connection defaults to a schema corresponding to the user name. If no user name is supplied then the user name (and hence current schema) defaults to APP.
However even though the current schema is set to the user name, that schema may not exist. A schema is only created by CREATE SCHEMA or creating an object (table etc.) in that schema (this is implicit schema creation).
The one exception to this is the APP schema, which is always created, though applications should not depend on that.
So you will see the schema not exists error if your application tries to access the current schema before any objects have been created in it. Possibilities are you try to perform a DROP TABLE before creating it, or try to SELECT from a table to see if it should be created or not, or when there is a problem with the sql for the very first object you try to create in a particular schema and no explicit CREATE SCHEMA was issued.
However even though the current schema is set to the user name, that schema may not exist. A schema is only created by CREATE SCHEMA or creating an object (table etc.) in that schema (this is implicit schema creation).
The one exception to this is the APP schema, which is always created, though applications should not depend on that.
So you will see the schema not exists error if your application tries to access the current schema before any objects have been created in it. Possibilities are you try to perform a DROP TABLE before creating it, or try to SELECT from a table to see if it should be created or not, or when there is a problem with the sql for the very first object you try to create in a particular schema and no explicit CREATE SCHEMA was issued.
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.