Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Problems with Derby

  1. #1
    Member tyeeeee1's Avatar
    Join Date
    Sep 2012
    Posts
    61
    Thanks
    31
    Thanked 2 Times in 2 Posts

    Default Problems with Derby

    I'm currently attempting to figure out how to use a Derby database in java. So-far I've been reading through this (Java For Complete Beginners - Databases) tutorial and I'm kinda-sorta sure that I've done most of this right but I'm a bit stuck at the moment.

    So-far my code looks like this:
    import java.sql.*;
     
    public class DataBaseTest 
    {
     
        public static void main(String args[])
        {
            int id = 1;
     
            try
            {
                String host = "jdbc:derby://localhost:1527/Test Database";
                String uName = "removedTheUsername";
                String uPass = "removedThePassword";
                Connection dbConnection = DriverManager.getConnection( host, uName, uPass);
     
                Statement statement = dbConnection.createStatement();
                String sql = "SELECT * FROM TESTTABLE";
                ResultSet resultSet = statement.executeQuery(sql);
     
                for(int i = 0; i < id; i++)
                {
                    resultSet.next();
                    if(i == id)
                    {
                        System.out.println(resultSet.getInt(1) + " " + resultSet.getString(2) + " " +resultSet.getInt(3));
                    }
                }
            }
            catch(Exception e)
            {
                e.printStackTrace();
            }
        }
    }

    It's pretty mush just mashed together since I'm still figuring this all out. The error that I'm getting is:

    run:
    java.sql.SQLSyntaxErrorException: Schema 'TYEEEEE1' 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 DataBaseTest.main(DataBaseTest.java:19)
    Caused by: org.apache.derby.client.am.SqlException: Schema 'TYEEEEE1' 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)
    	... 2 more
    BUILD SUCCESSFUL (total time: 0 seconds)

    The database is named 'Test Database' and the table I'm trying to access is called 'TESTTABLE'.
    I've checked out line 19 where the first error says something is going wrong but I don't know enough about half of these statements to figure out what's going wrong. If anyone can see where I went wrong and explain how to fix it that would help!


  2. #2
    Member tyeeeee1's Avatar
    Join Date
    Sep 2012
    Posts
    61
    Thanks
    31
    Thanked 2 Times in 2 Posts

    Default Re: Problems with Derby

    Solution found. Apparently, due to a space within the database name, it was messing up. If anyone encounters a problem similar to mine just check out this page for some information on a fix https://db.apache.org/derby/faq.html#schema_exist.

Similar Threads

  1. where is my JavaDB/Derby?
    By chronoz13 in forum JDBC & Databases
    Replies: 3
    Last Post: December 9th, 2012, 09:00 PM
  2. help java Db derby or my sql
    By Am3Egy in forum JDBC & Databases
    Replies: 3
    Last Post: August 10th, 2011, 12:05 PM
  3. Replies: 0
    Last Post: April 3rd, 2011, 10:58 AM
  4. How to deploy derby database?
    By Muaz_Sh in forum JDBC & Databases
    Replies: 8
    Last Post: March 17th, 2011, 09:23 AM
  5. Java (Derby) Help
    By Neon612 in forum JDBC & Databases
    Replies: 3
    Last Post: August 19th, 2010, 08:40 PM