• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unexpected Token

 
Barry Andrews
Ranch Hand
Posts: 529
C++ Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If someone could please help with these errors I am having I would greatly appreciate it. I have some code that connects to a database and inserts some information. When I run the application, I get:
COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2/Windows 95] SQL0104N An unexpected token "INSERT INTO WEBSITES VALUES('http:/" was found following "BEGIN-OF-STATEMENT". Expected tokens may include: "<rename_table>". SQLSTATE=42601
The database does get the INSERT but the exception is thrown. For the remaining INSERTS in the application, I get the same exception thrown, but nothing is entered into the database.
Can someone tell me what this means? Is the String updateString in my code written correctly? Please help! Many thanks!!!

if(connectionMade == true)
updateDatabase();
}//end of tryConnection();

public void updateDatabase()
{

try
{
Class.forName(urlForDatabase);
}
catch (Exception e)
{
e.printStackTrace();
}
try
{
databaseCon = DriverManager.getConnection("jdbc:db2 ISCOVER");
stmt = databaseCon.createStatement();
updateString = "INSERT INTO WEBSITES " + " VALUES('" + urlToTry + "'," + connectionCounter + ",'" + tempString + "')";
stmt.executeUpdate(updateString);
connectionMade = false; //return it back to false for next connection attempt
}
catch (Exception e)
{
e.printStackTrace();
}
try
{
stmt.close();
databaseCon.close();
}
catch (Exception e)
{
e.printStackTrace();
}
}//end of updateDatabase()
//Note: Columns for the WEBSITES table accepts the following in
//order VARCHAR(32), INTEGER, VARCHAR(1000)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic