aspose file tools*
The moose likes JDBC and the fly likes Problem connecting to my database. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Problem connecting to my database." Watch "Problem connecting to my database." New topic
Author

Problem connecting to my database.

Greg Funston
Ranch Hand

Joined: Feb 09, 2011
Posts: 81

Hi, I have been working away for a while now on getting familiar with Java EE and I am trying to connect to a database. I believe I have been successful but I now have what seems to be a syntax problem with SQL. My error being produced by my testpage is

" javax.servlet.ServletException:
USE affablebean;
SELECT (*) FROM 'product';
: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT (*) FROM 'product'' at line 3"

As you can see I am working through the affablebean tutorial. I believe I have a connection to the database but I am getting SQL syntax errors now. Can someone please point me in the right direction for the solution to my problem.

Thanks,

Greg Funston
Greg Funston
Ranch Hand

Joined: Feb 09, 2011
Posts: 81

Thanks, I found the solution to my problem. I had a statement which stated which database to use "USE affablebean" it was in the same place as the next statement
"SELECT * FROM tablename". I placed the first statement in a separate tag <sql:update> and the page now works correctly.



Cheers,

Greg Funston
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem connecting to my database.