Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JDBC Maven Dependency in pom.xml

I have created a Maven Project in Eclipse (EE Developer Kepler version) and I have in my pom.xml file the following error, "Missing artifact com.oracle:ojdbc7:jar:12.1.0.1" in this code

<dependency>
    <groupId>com.oracle</groupId>
    <artifactId>ojdbc7</artifactId>
    <version>12.1.0.1</version>
</dependency>

I know that I have to add the jdbc repository into my .m2 folder. I have done so by downloading the ojdbc7.jar from the following link http://www.oracle.com/technetwork/database/features/jdbc/jdbc-drivers-12c-download-1958347.html

With that archive donwloaded, I open a terminal (I have Debian installed) and run the following command as root

mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc7  
-Dversion=12.1.0.1 -Dpackaging=jar -Dfile=ojdbc7.jar -DgeneratePom=true

After that, I got as an output BUILD SUCCESS, and if I go to the .m2 folder I see in the com->oracle->ojdbc7 two files called "ojdbc7-12.1.0.1.jar.lastUpdated" and "ojdbc7-12.1.0.1.pom.lastUpdated" but still Eclipse brings me the code into the pom.xml file as an error

What can I do to fix this?

like image 922
a.ras2002 Avatar asked Apr 08 '14 19:04

a.ras2002


People also ask

What Maven dependencies are available for the Oracle JDBC driver?

Since September 2019, the Oracle JDBC Driver is available on Maven Central. For Java 11 and newer version, use the following Maven dependency: For Java 8, use the ojdbc8 artifact instead: For Java 6, use the ojdbc6 artifact instead:

How do I add the MySQL JDBC driver to Maven?

The MySQL Driver is available on Maven Central, so just add the following dependency to your pom.xml file: Use this Maven Central link to get the latest artifact version for the MySQL JDBC Driver.

How to get Apache Derby JDBC driver from Maven Central?

Use the following Maven dependency to get the Apache Derby JDBC Driver from Maven Central: To get the latest version of the Derby JDBC Driver, use this Maven Central query link. That’s it! If you enjoyed this article, I bet you are going to love my Book and Video Courses as well.

How do I get the H2 JDBC driver from Maven Central?

The H2 database JDBC Driver is available on Maven Central, so you can use the following Maven dependency: This Maven Central link will tell you which is the latest version of the H2 JDBC artifact. Use the following Maven dependency to get the Apache Derby JDBC Driver from Maven Central:


2 Answers

If you are using eclipse, go to the folder where you have your pom and try this commands:

mvn -Declipse.workspace=<path-to-your-eclipse-workspace> eclipse:add-maven-repo
mvn eclipse:eclipse

I haven't tried it in Linux, but it should fix your dependencies / eclipse path issues.

like image 52
robertoia Avatar answered Oct 22 '22 00:10

robertoia


  1. From the menu, select "Window-->Show View-->Other..."
  2. In the dialog, select "Maven-->Maven Repositories" and hit OK.
  3. In the Maven Repositories view, right-click "Local Repositories-->Local Repository" and select "Rebuild Index" from the popup menu. If asked if you're sure you want to rebuild the index, hit OK.

If that doesn't work (it should), try right-clicking the project in the Explorer view, selecting "Maven-->Update Project..." from the popup menu, ensuring that "Update dependencies" is checked in the dialog that appears, and hitting OK.

BTW, you probably want to add <scope>runtime</scope> to your dependency element in the pom file, although that's not related to your issue.

like image 40
Alvin Thompson Avatar answered Oct 22 '22 00:10

Alvin Thompson