Am trying to use jdbc connection in my Java EE6 application(class name VisualizerRepository.java), i have the jdbc driver in nexus repository
The class has to execute a stored procedure and print the result of the procedure. Since JPA 2.0 has no support on calling procedures am using jdbc.
package com.nfsmith.crm.data.repository;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.SQLException;
import javax.sql.DataSource;
import oracle.jdbc.OracleTypes;
import org.jboss.logging.Logger;
@Named
@ApplicationScoped
public class VisualizerRepository
{
DataSource datasource;
Connection connection;
CallableStatement statement;
@PostConstruct
public void initDBConnection()
{
InitialContext context;
try
{
context = new InitialContext();
datasource = (DataSource) context.lookup("java:jboss/datasources/partmatchDatasource");
connection = null;
statement = null;
connection = datasource.getConnection();
}
catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void getJSonDataList()
{
try {
statement = connection.prepareCall("{call crm.PKG_CRM_RELATIONSHIP.getOrgViewDataJason(?,?,?)}");
int owner = 48156;
statement.setInt(1, owner);
int site = 10;
statement.setInt(2, site);
statement.registerOutParameter(3, OracleTypes.CURSOR);
statement.execute();
}
catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally
{
try {
statement.close();
connection.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
when I do the build am seeing the compilation error saying package oracle.jdbc does not exist and cannot find symbol
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/Users/rpalle/workspace/CRM/smith-crm-web/src/main/java/com/nfsmith/crm/data/repository/VisualizerRepository.java:[15,19] package oracle.jdbc does not exist
[ERROR] /C:/Users/rpalle/workspace/CRM/smith-crm-web/src/main/java/com/nfsmith/crm/data/repository/VisualizerRepository.java:[66,51] cannot find symbol
symbol: variable OracleTypes
location: class com.nfsmith.crm.data.repository.VisualizerRepository
[INFO] 2 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Smith CRM ......................................... SUCCESS [0.823s]
[INFO] Smith CRM Web ..................................... FAILURE [4.775s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.410s
[INFO] Finished at: Wed Aug 07 13:48:32 CDT 2013
[INFO] Final Memory: 36M/530M
[INFO] ------------------------------------------------------------------------
[WARNING] The requested profile "CRM_local" could not be activated because it does not exist.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project smith-crm-web: Compilation failure: Compilation failure:
[ERROR] /C:/Users/rpalle/workspace/CRM/smith-crm-web/src/main/java/com/nfsmith/crm/data/repository/VisualizerRepository.java:[15,19] package oracle.jdbc does not exist
[ERROR] /C:/Users/rpalle/workspace/CRM/smith-crm-web/src/main/java/com/nfsmith/crm/data/repository/VisualizerRepository.java:[66,51] cannot find symbol
[ERROR] symbol: variable OracleTypes
[ERROR] location: class com.nfsmith.crm.data.repository.VisualizerRepository
[ERROR] -> [Help 1]
The ojdbc jar is not in public maven repositories. You can add the jar to local repository manually.
Download the jar from:
Install in your repository
mvn install:install-file -Dfile={Path/to/your/ojdbc.jar} -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0 -Dpackaging=jar
Use in your pom
<dependency> <groupId>com.oracle</groupId> <artifactId>ojdbc6</artifactId> <version>11.2.0</version> </dependency>
Oracle JDBC drivers are accessible from Oracle Maven Repository with some additional security related steps.
Check the blog "Get Oracle JDBC drivers and UCP from Oracle Maven Repository (without IDEs)" for more details.
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