标题
我试图在我的 Java EE6 应用程序(类名 VisualizerRepository.java)中使用 jdbc 连接,我在 nexus 存储库中有 jdbc 驱动程序
该类必须执行一个存储过程并打印该过程的结果。由于 JPA 2.0 不支持调用过程,因此使用 jdbc。
包 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();
}
}
}
}
当我进行构建时看到编译错误说包 oracle.jdbc 不存在并且找不到符号
[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]