Link to home
Start Free TrialLog in
Avatar of ManikandanBalachandran
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_class">org.apache.derby.jdbc.ClientDriver</property>
<property name="hibernate.connection.url">jdbc:derby://localhost:1527/AutoDB;</property>
<property name="hibernate.dialect">org.hibernate.dialect.DerbyDialect</property>
<property name="hibernate.connection.username">sa</property>
<property name="hibernate.connection.password">hidepassword</property>
            
<!-- Specific the default schema to connect  -->
<property name="hibernate.default_schema">APP</property>
<!-- Specific the default schema to connect  -->
<property name="hibernate.default_catalog">APP</property>
       
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">300</property>
       
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>
       
<!-- Disable the second-level cache  -->
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
       
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">false</property>
       
<!-- Drop and re-create the database schema on startup -->
<property name="hbm2ddl.auto">update</property>


Avatar of Sathish David  Kumar N
Sathish David Kumar N
Flag of India image

when you defind the sessionFactory property that time you can specify the  default_shema then it will apply all calss mapping files !!
Avatar of ManikandanBalachandran
ManikandanBalachandran

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 ??
Please give a sample hbm file for setting schema
ASKER CERTIFIED SOLUTION
Avatar of anilallewar
anilallewar
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
<class name="com.tts.papa.javabeans.DocApprovalDetails" table="DOC_APPROVAL_DETAILS" 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 ...
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.
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.