engma engma - 7 months ago 92
Java Question

Java db schema does not exist (netbeans 7)

I created a java db database using netbeans 7 services, I used the java embedded driver to connect to the java db.
I can find my database under the connection in the java database, under a schema called ROOT.

This is my java db connection name:

jdbc:derby:AddressBook [root on ROOT]

But, when i try to use that schema in my project i get an exception that states

Caused by: ERROR 42Y07: Schema 'ROOT' does not exist
at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
at org.apache.derby.impl.sql.catalog.DataDictionaryImpl.getSchemaDescriptor(Unknown Source)

The error apears in the select statement. what should i do to make it readable in the project?

This is my code:

private static final String URL = "jdbc:derby:AddressBook";
private static final String USERNAME = "root";
private static final String PASSWORD = "cs101";

private Connection connection = null; // manages connection
private PreparedStatement selectAllPeople = null;
private PreparedStatement selectPeopleByLastName = null;
private PreparedStatement insertNewPerson = null;

// constructor
public PersonQueries()
connection =
DriverManager.getConnection( URL, USERNAME, PASSWORD );

// create query that selects all entries in the AddressBook
selectAllPeople =
connection.prepareStatement( "SELECT * FROM ROOT.Addresses" )

Answer Source

Try putting this code before creating the connection

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download