unable to connect to a mySQL database
I have developed a small JSP application that uses a mySQL database, a single JSP page (which simply displays the contents of a table in my db), and a servlet, which contains the entity manager and sql statements. I link to the database using the xml file (rather than in the code), which contains this:
Code:
...
<properties>
<property name="openjpa.ConnectionURL" value="jdbc:mysql://localhost:3306/baseball8"/>
<property name="openjpa.ConnectionDriverName" value="com.mysql.jdbc.Driver"/>
<property name="openjpa.ConnectionUserName" value="root"/>
<property name="openjpa.ConnectionPassword" value="password"/>
<property name="openjpa.Log" value="DefaultLevel=WARN, Tool=INFO"/>
</properties>
...
When I access the servlet from a web browser, I get the following error (which is actually quite detailed; last line is the error):
Quote:
<openjpa-1.2.1-r752877:753278 nonfatal general error> org.apache.openjpa.persistence.PersistenceException: There were errors initializing your configuration: <openjpa-1.2.1-r752877:753278 fatal user error> org.apache.openjpa.util.UserException: A connection could not be obtained for driver class "com.mysql.jdbc.Driver" and URL "jdbc:mysql://localhost:3306/baseball8". You may have specified an invalid URL.
It says my URL is invalid. I KNOW this is the right URL as I have seen it countless places on the net. If I browse to that url in my web browser, I get an octet stream. If I use the command line interface for mysql, it works. If I connect to the sql database using Eclipse, it works. I can connect just fine. I do have the mysql connector in my class path, as well as the opengpl Apache libraries.
I am completely stumped as to the cause of the bug! Any help (or even guesses!) would be greatly appreciated.
Thanks,
Niel
Re: unable to connect to a mySQL database
- Do you have the driver set for the server?
- Try the url without the port: //localhost/baseball8
Re: unable to connect to a mySQL database
Wow after several days of debugging, I finally figured it out. The associated *.jar files for the mySQL connector and taglibs have to be copied to the Apache server's "lib" directory, despite them being in the class path for the Eclipse project and also exported from there.
Niel