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()
{
try
{
connection =
DriverManager.getConnection( URL, USERNAME, PASSWORD );
// create query that selects all entries in the AddressBook
selectAllPeople =
connection.prepareStatement( "SELECT * FROM ROOT.Addresses" )
在创建连接之前尝试放置此代码
Class.forName("org.apache.derby.jdbc.ClientDriver")
when using embedded derby nb has placed your db in a specific location. in my NB 7.2 install it defaults to: C:\\Users\\James.netbeans-derby. you need to make sure your app is reading the same db file by setting the derby home property:
System.setProperty("derby.system.home", "C:\Users\James\.netbeans-derby");
or like this:
System.setProperty("derby.system.home",
System.getProperty("user.home")+".netbeans-derby");
Good luck!
从Derby数据库的属性中获取完整URL,并获取连接以解决问题
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.