[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

schema does not exist - Apache derby

Posted on 2010-03-24
11
Medium Priority
?
3,771 Views
Last Modified: 2013-12-15
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>


0
Comment
  • 4
  • 2
  • 2
  • +2
10 Comments
 
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 28458994
when you defind the sessionFactory property that time you can specify the  default_shema then it will apply all calss mapping files !!
0
 

Author Comment

by:ManikandanBalachandran
ID: 28553377
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?
0
 
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 28562423
r u using hbm file ??

yes means set shema there ! and remove from your xml file and check ??
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 

Author Comment

by:ManikandanBalachandran
ID: 29645407
Please give a sample hbm file for setting schema
0
 
LVL 11

Accepted Solution

by:
anilallewar earned 1000 total points
ID: 29792264
If a database is created in Derby using the embedded driver and no user name is specified, the default schema used becomes APP. Therefore any tables created in the database have a schema name of APP. However, when creating a Derby database using the Network Server, the value for the schema becomes the value of the username used to connect with as part of the database URL.

This is an inherant limitation with derby and you cannot specify the default schema. There are 2 options that you can use
1. Always prepend schema name to table name (for example APP.table1  instead of table1)
2. Use the derby embedded driver to run derby in embedded mode; but remember that in embedded mode data CANNOT be accessed (and manipulated) with third party tools. To do this, change the driver to

<property name="hibernate.connection.driver_class">org.apache.derby.jdbc.EmbeddedDriver</property>
<property name="hibernate.connection.url">jdbc:derby:AutoDB;</property>

For details on derby embedded mode, check out
http://db.apache.org/derby/papers/DerbyTut/embedded_intro.html
0
 
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 29815795
<class name="com.tts.papa.javabeans.DocApprovalDetails" table="DOC_APPROVAL_DETAILS" shema ="check">
0
 
LVL 11

Expert Comment

by:anilallewar
ID: 29860934
@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.
0
 
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 29907250
Is it ...  I didnt work in derby . i thought its apacy product so we can use hbm ...

Thanks ...
0
 
LVL 2

Expert Comment

by:deepakkumarc11
ID: 31263771
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.
0
 
LVL 61

Expert Comment

by:Kevin Cross
ID: 36042199
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

607 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question