I want to add the oracle jdbc driver to my project as dependency (runtime scope) - ojdbc14. In MVNrepository site the dependency to put in the POM is:
<dependency> <groupId>com.oracle</groupId> <artifactId>ojdbc14</artifactId> <version>10.2.0.3.0</version> </dependency>
of course this does't work as it is not in the central repository used by maven. 2 questions:
How do I find a repository (if any) that contains this artifact?
How do I add it so that Maven will use it?
You can determine the version of the JDBC driver that you installed, by calling the getDriverVersion method of the OracleDatabaseMetaData class. You can also determine the version of the JDBC driver by executing the following commands: java -jar ojdbc5. jar.
ojdbc (version 19.3. 0.0)
How do I find a repository (if any) that contains this artifact?
Unfortunately due the binary license there is no public repository with the Oracle Driver JAR. This happens with many dependencies but is not Maven's fault. If you happen to find a public repository containing the JAR you can be sure that is illegal.
How do I add it so that Maven will use it?
Some JARs that can't be added due to license reasons have a pom entry in the Maven Central repo. Just check it out, it contains the vendor's preferred Maven info:
<groupId>com.oracle</groupId> <artifactId>ojdbc14</artifactId> <version>10.2.0.3.0</version>
...and the URL to download the file which in this case is http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/index.html.
Once you've downloaded the JAR just add it to your computer repository with (note I pulled the groupId, artifactId and version from the POM):
mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc14 \ -Dversion=10.2.0.3.0 -Dpackaging=jar -Dfile=ojdbc.jar -DgeneratePom=true
The last parameter for generating a POM will save you from pom.xml warnings
If your team has a local Maven repository this guide might be helpful to upload the JAR there.
For whatever reason, I could not get any of the above solutions to work. (Still can't.)
What I did instead was to include the jar in my project (blech) and then create a "system" dependency for it that indicates the path to the jar. It's probably not the RIGHT way to do it, but it does work. And it eliminates the need for the other developers on the team (or the guy setting up the build server) to put the jar in their local repositories.
UPDATE: This solution works for me when I run Hibernate Tools. It does NOT appear to work for building the WAR file, however. It doesn't include the ojdbc6.jar file in the target WAR file.
1) Create a directory called "lib" in the root of your project.
2) Copy the ojdbc6.jar file there (whatever the jar is called.)
3) Create a dependency that looks something like this:
<dependency> <groupId>com.oracle</groupId> <artifactId>ojdbc</artifactId> <version>14</version> <scope>system</scope> <systemPath>${basedir}/lib/ojdbc6.jar</systemPath> <!-- must match file name --> </dependency>
Ugly, but works for me.
To include the files in the war file add the following to your pom
<build> <finalName>MyAppName</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <configuration> <webResources> <resource> <directory>${basedir}/src/main/java</directory> <targetPath>WEB-INF/classes</targetPath> <includes> <include>**/*.properties</include> <include>**/*.xml</include> <include>**/*.css</include> <include>**/*.html</include> </includes> </resource> <resource> <directory>${basedir}/lib</directory> <targetPath>WEB-INF/lib</targetPath> <includes> <include>**/*.jar</include> </includes> </resource> </webResources> </configuration> </plugin> <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> </plugins> </build>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With