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 4 of 4

Thread: java.sql.SQLSyntaxErrorException

  1. #1
    Junior Member
    Join Date
    May 2011
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question java.sql.SQLSyntaxErrorException

    Hello all,

    I am using NetBeans with JavaDB using the embedded driver. When I try to write to my database, I keep getting the error java.sql.SQLSyntaxErrorException the table does not exist.

    I use the sql statement String sql = "INSERT INTO APP.tblname (tblID, fname) VALUES (1, blue)"; and then I get java.sql.SQLSyntaxErrorException: Table/View 'APP.tblname' does not exist.

    also when I use String sql = "INSERT INTO tblname (tblID, fname) VALUES (1, blue)"; I still get an error that the table does not exist, even though my tables are visible under the Services console view in Netbeans.

    This is my connection pool:

    Connection conn;
           String driver = "org.apache.derby.jdbc.EmbeddedDriver";
           String connectionURL = "jdbc:derby:";
           String dbName = "gameDB"; // the name of the database
     
     
            try {
          Class.forName(driver);
        } catch (java.lang.ClassNotFoundException e) {
          e.printStackTrace();
        }
        try {
          conn = DriverManager.getConnection(connectionURL + dbName);

    I notice also when I try to connect the database by right clicking and clicking on connect, from the services view in Netbeans, it keeps bringing up the clientdriver connection node, even though the embedded driver connection node I want to use is there. So I just right click on the embedded driver connection mode and then click connect so I don't get the message no driver found, only that it does not appear to see that tables under the "APP" schema in my embedded driver.

    Please Please help!

  2. #2
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: java.sql.SQLSyntaxErrorException

    String sql = "INSERT INTO APP.tblname (tblID, fname) VALUES (1, blue)";

    Is tblname a variable or the actual name of the table in the database? Either way use a PreparedStatement instead.

  3. #3
    Junior Member
    Join Date
    May 2011
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: java.sql.SQLSyntaxErrorException

    Thanks Junky.

    I still get the error whether I use Statement or PreparedStatement.

  4. #4
    Junior Member
    Join Date
    May 2011
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: java.sql.SQLSyntaxErrorException

    Can anyone please help me with this. I keep getting this exception error when I try to write to my Java database.

    java.lang.ClassNotFoundException: org.apache.derby.jdbc.EmbeddedDriver

    the derby.jar files are located in C:\Program Files\Sun\JavaDB\lib, and I have also added the library to the project in NetBeans, but when I try to write to the database I get the above error.

    Please somebody help!