问题
I am using Netbeans 7.4 to build my application. And also, I am using embedded java db. Now, I want to generate my JPA entities from my database from my database.
But, when I
rightclick my package -> New -> Entity classes from database
, select my database, Available Tables
is not showing up even a single one of the tables inside ANK
schema.
One more strange thing I noticed is when I connect my db from Netbeans services tab, two schema options appear. First, APP
in bold, second Other schemas
. Schema APP
don't have any tables. The tables are in ANK
schema in Other schemas
.
Can anybody tell me where I could have gone wrong?
I don't even know if I should be using java db, or I should go for pretty appealing h2, HSQL or some matured db like mysql.
回答1:
The Nebeans interface to Derby is a bit tricky.
When creating a new database, only the APP schema is created by default (except for the SYS* schemas).
When you connect to the database without specifying a username, your default schema becomes APP
When connecting as user john, your default schema becomes john, BUT the schema john is NOT created, until you create an SQL object in it.
This means that if you create an initial connection to Derby in Netbeans as user john, you cannot choose john as the schema for the connection in the pull-down menu, because it has not been created yet. If you then choose another schema, create your table, disconnect and then create another connection you will be able to choose john as your schema, and you will find the table you created with the previous connection.
Even though you chose a different schema in the pull-down menu for the first connection, a schema with the same name as the username you connect as is created and set as default before starting to execute the create table statement.
来源:https://stackoverflow.com/questions/21418694/netbeans-7-4-creating-entity-classes-jpa-from-java-db-embedded-database