Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unable to connect o MariaDB JDBC Driver in Eclipse EE Luna

 
Lluvian Brown
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Everyone!

I need some assistance connecting my Eclipse application to my MariaDB web project.

System:
Mac OS Yosemite
Java 8
Eclipse EE Juno
MariaDB

I have a database that I manually created in MariaDB using MySQL Workbench called webshop.

The next step I did was add my MariaDB project to my build path.
1. Right click project.
2. Build Path -> Configure Build Path
3. Select Libraries and Add External JAR's
4. Clicked OK.

Now I added it to my code.

and


In my catch area below Class.forName for driver I have an exception that says cant load database driver. This is how I know my driver can not be found.

What did I do wrong and what will I need to resolve this issue?
 
Dave Tolls
Ranch Hand
Posts: 2112
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you added the jar file containing that Driver class into your runtime classpath?
 
Lluvian Brown
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This was the step I used:

The next step I did was add my MariaDB project to my build path.
1. Right click project.
2. Build Path -> Configure Build Path
3. Select Libraries and Add External JAR's
4. Clicked OK.

Is adding it to the runtime path different from that step? If so, I did not add it and will need to look into how to accomplish that.
 
Dave Tolls
Ranch Hand
Posts: 2112
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure what you mean by "my MariaDB project".
Have you put the jar file containing the org.mariadb.jdbc.Driver class in it on the classpath?
Looking at the MariaDB site I am referring to this jar file, downloadable from here.
 
Lluvian Brown
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry about the confusion. This is a basic Java EE web project with MariaDB as the backend database. I am trying to connect to MariaDB within Eclipse. I did select to add the mariadb jdbc driver using the build path configuration options. In the Library tab I selected to add external jar. I can see my jar there in the project and navigate to the Driver.class file. I also restart Tomcat7. What I am not sure of it there was another step I had to take. I even tried adding the jar file to Web-INF/lib folder and that did not work.
 
Lluvian Brown
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What makes this even confusing is I did the exact same steps in Ubuntu and it works!

I just need to figure out what is wrong in OSX because that is my development environment.
 
Stefan Evans
Bartender
Posts: 1807
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

> 3. Select Libraries and Add External JAR's
> 4. Clicked OK.
I'm presuming there is a step in between these where you find and select an appropriate jar file with the driver class in it.

> I also restart Tomcat7
What does Tomcat have to do with this? You didn't mention Tomcat before. That changes things a little.

You have added some code. Where does this code run? Is it a Unit test? A stand alone application? In Tomcat?

Given that Tomcat is in the picture, probably the best place for the driver to live is Tomcat's lib directory.
The reason being, you can then define a JNDI Data source on your server, and reference that from your classes rather than create your own Database connection.

My suggestions
- add the driver jar file to the Tomcat/lib directory
- restart Tomcat

If it still doesn't work, please post the full error message with a stack trace.
 
Lluvian Brown
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ubuntu Linux:
Add External Jar File Works ONLY Solution I found

Mac OSX Yosemite:
Copy paste jar file in WEB-INF/lib folder ONLY Solution I found

Both solution do not work for me on the reversed on either systems but I got it working and can keep learning.

FYI - I have not tried adding the jar file to Tomcat and if that is best practice I will try it. Thank you all for your assistance!!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic