What The H ell Is Going On Here?!

i try connecting to a database called "CONTACTS" using connection = DriverManager.getConnection("jdbc:derby://localhost:1527/CONTACTS");

but when i run my application i get this exception:

java.sql.SQLSyntaxErrorException: Table/View'CONTACTS' does not exist.

at org.apache.derby.client.am.SQLExceptionFactory40.getSQLException(Unknown Source)

at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)

at org.apache.derby.client.am.Statement.executeQuery(Unknown Source)

at JavaPhonebook.ContactIO.loadContacts(ContactIO.java:73)

at JavaPhonebook.JavaPhonebook.<init>(JavaPhonebook.java:81)

at JavaPhonebook.JavaPhonebook.main(JavaPhonebook.java:482)

Caused by: org.apache.derby.client.am.SqlException: Table/View'CONTACTS' does not exist.

at org.apache.derby.client.am.Statement.completeSqlca(Unknown Source)

at org.apache.derby.client.net.NetStatementReply.parsePrepareError(Unknown Source)

at org.apache.derby.client.net.NetStatementReply.parsePRPSQLSTTreply(Unknown Source)

at org.apache.derby.client.net.NetStatementReply.readPrepareDescribeOutput(Unknown Source)

at org.apache.derby.client.net.StatementReply.readPrepareDescribeOutput(Unknown Source)

at org.apache.derby.client.net.NetStatement.readPrepareDescribeOutput_(Unknown Source)

at org.apache.derby.client.am.Statement.readPrepareDescribeOutput(Unknown Source)

at org.apache.derby.client.am.Statement.flowExecute(Unknown Source)

at org.apache.derby.client.am.Statement.executeQueryX(Unknown Source)

... 4 more

so i think ok i must connect to a table inside of the database. so i connect to the "A" table inside of the "CONTACTS" database connection = DriverManager.getConnection("jdbc:derby://localhost:1527/A");

but now i get another exception:

java.sql.SQLTransientConnectionException: The connection was refused because the database A was not found.

at org.apache.derby.client.am.SQLExceptionFactory40.getSQLException(Unknown Source)

at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)

at org.apache.derby.jdbc.ClientDriver.connect(Unknown Source)

at java.sql.DriverManager.getConnection(DriverManager.java:582)

at java.sql.DriverManager.getConnection(DriverManager.java:207)

at JavaPhonebook.ContactIO.<init>(ContactIO.java:44)

at JavaPhonebook.JavaPhonebook.<init>(JavaPhonebook.java:80)

at JavaPhonebook.JavaPhonebook.main(JavaPhonebook.java:482)

Caused by: org.apache.derby.client.am.DisconnectException: The connection was refused because the database A was not found.

at org.apache.derby.client.net.NetConnectionReply.parseRDBNFNRM(Unknown Source)

at org.apache.derby.client.net.NetConnectionReply.parseAccessRdbError(Unknown Source)

at org.apache.derby.client.net.NetConnectionReply.parseACCRDBreply(Unknown Source)

at org.apache.derby.client.net.NetConnectionReply.readAccessDatabase(Unknown Source)

at org.apache.derby.client.net.NetConnection.readSecurityCheckAndAccessRdb(Unknown Source)

at org.apache.derby.client.net.NetConnection.flowSecurityCheckAndAccessRdb(Unknown Source)

at org.apache.derby.client.net.NetConnection.flowUSRIDONLconnect(Unknown Source)

at org.apache.derby.client.net.NetConnection.flowConnect(Unknown Source)

at org.apache.derby.client.net.NetConnection.<init>(Unknown Source)

at org.apache.derby.client.net.NetConnection40.<init>(Unknown Source)

at org.apache.derby.client.net.ClientJDBCObjectFactoryImpl40.newNetConnection(Unknown Source)

... 6 more

Exception in thread"main" java.lang.NullPointerException

at JavaPhonebook.ContactIO.loadContacts(ContactIO.java:72)

at JavaPhonebook.JavaPhonebook.<init>(JavaPhonebook.java:81)

at JavaPhonebook.JavaPhonebook.main(JavaPhonebook.java:482)

what the h ell is goin on here?! first i try to connect to a database but it thinks im trying to connect to a table. and when i try connecting to a table it thinks im connecting to a database!

[4291 byte] By [Alex1989a] at [2007-11-27 5:48:36]
# 1
You don't connect to a table - you connect to a database, as a user. One connection can access all the tables of a database.
malcolmmca at 2007-7-12 15:34:16 > top of Java-index,Java Essentials,Java Programming...
# 2

It looks to me that the exceptions are in two different places.

The first one manages to connect to the "CONTACTS" database but later fails when it tries to do a query on the contacts table.

The second fails trying to connect to the non-existent "A" database (you connect to a database not a table).

jbisha at 2007-7-12 15:34:16 > top of Java-index,Java Essentials,Java Programming...
# 3
ok i figured the problem out. i was connecting to the CONTACTS database but i was still using code from my old database (CONTACT_DATABASE), which had a table inside of it called CONTACTS :)
Alex1989a at 2007-7-12 15:34:16 > top of Java-index,Java Essentials,Java Programming...