How Do You Troubleshoot the Java Program Message “com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Unknown database foobar”?

Problem scenario
Your Java program returns this message: "com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Unknown database foobar"

What should you do?

Possible solution #1
Are you using Amazon Aurora? AWS has a MySQL PaaS offering. You may have a section of the Java code that looks like this:

Connection con=DriverManager.getConnection("jdbc:mysql://")

Remove the last "foobar" from the end. The connection string should look like this for Aurora databases:


Recompile the program. Execute it again. (We know this is contrary to the documented and canonical construction of MySQL strings for JDBC connectivity. The root cause of your problem may have been that Aurora MySQL databases are different in this respect.)

Possible solution #2 The database name "foobar" does not exist. Did you type the server or database name incorrectly? Have you created the database? Did you not use to the correct server?

Leave a comment

Your email address will not be published. Required fields are marked *