Friday, April 15, 2011

Published 4/15/2011 by with 0 comment

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown database

Trying to connect to a MySQL server from Java? But seeing the error "Unknown database"?

The reason is that the database does not exist in the MySQL server. You might have accidentally misspelled the database name in the JDBC connection url.

See the code below:
Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/sales","username","password");

Here sales is the database name. If you misspelled this or the database sales does not exist in the server, you see this error message.

    email this       edit

0 comments:

Post a Comment