0

I'm facing difficulties starting my first web Java EE application through IntelliJ Idea 15 (on linux mint). My server Tomcat is on, jre seems to be ok, and mySql database access too. But i don't find out how to put the right jdbc driver and where. I searched for informations on forums and documentations but with no success. Does someone can help, or give the good related topic? Thx!

public class PoolConnection {
    public static Connection getConnection() throws SQLException{

        Connection cnx=null;

        // load JNDI directory
        InitialContext jndi = null;
        try {
            jndi = new InitialContext();
        } catch (NamingException ne) {
            ne.printStackTrace();
            throw new SQLException("unable to reach the jndi tree");
        }

        // Search connections pool in directory
        DataSource ds = null;
        try {
            ds=(DataSource) jndi.lookup("java:comp/env/jdbc/myProject");
        } catch (NamingException ne) {
            ne.printStackTrace();
            throw new SQLException("unable to find connection pool in jndi directory");
        }

        // Set up a connection from the pool
        cnx=ds.getConnection();

        return cnx;
    }
}
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
bertrand
  • 1
  • 1

0 Answers0