I have a Java class which connects to an Oracle database and a JSP page, in which I am trying to call the function which connects to the database
I am getting a NullPointerException when the function is called.
My Java code:
public class DBConnection
{
public Connection getConnection() throws Exception
{
Connection con = null;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
con = DriverManager.getConnection(the correct code);
} catch (ClassNotFoundException e) {
e.printStackTrace();
throw e;
}
catch (SQLException e) {
e.printStackTrace();
throw e;
}
}
}
and my JSP page:
<% DBConnection db=new DBConnection();
db.getConnection();
%>
Where am I going wrong?