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:
Code Java:
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!
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.
Re: java.sql.SQLSyntaxErrorException
Thanks Junky.
I still get the error whether I use Statement or PreparedStatement.
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.
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. :confused:
Please somebody help!