Problem with Oracle OJDBC6

0

I have a Maven Module project of Liferay 7, which I want to implement a connection to Oracle through the OJDBC6, I have my connection which is the following:

public static Connection getConnection() {
    if (connection != null) {
        return connection;
    } else {
        try {
            Class.forName("oracle.jdbc.driver.OracleDriver");
            connection = DriverManager.getConnection("miURL", "miUsuario",
                    "miPass");
        } catch (ClassNotFoundException cnfe) {
            System.out.println(cnfe);
        } catch (SQLException sqe) {
            System.out.println(sqe);
        }
        return connection;
    }
}

Obviously I have a DAO class where I use my connection, and when I use my DAO in my controller I get the following connection error:

  

java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver

I have searched many pages and implemented some of these solutions:

  • Place the JAR ojdbc6 in tomcat8 / lib / ext
  • Place the jar in tomcat8 / WebApps / Root / lib /
  • Place jar in the path of java
  • Place the jar in the maven repository and place the dependency in the pom.xml of the project.
  • Among other similar ... And until now nothing has worked for me, someone will have some other solution?

        
    asked by Marco Ramirez 29.03.2017 в 22:25
    source

    1 answer

    2

    I have managed to solve the problem, I had to make the connection using a Service Builder link in this way I have separated my data access layer with the driver layer and data model.

    I also had to add the jar OJDBC and also a jar for liferay support oracle downloaded from here link in TOMCAT_HOME / webApps / ROOT / lib and configure the portal-ext.xml file and restart the server and go. I hope and it can be of some use to you.

        
    answered by 31.03.2017 / 21:46
    source