Null Pointer, som jeg ikke fatter hvorfor kommer
Dette siger min Tomcatjava.lang.NullPointerException
use.DatabaseContact.getCNALatest5(DatabaseContact.java:46)
org.apache.jsp.news_jsp._jspService(news_jsp.java:51)
Linie 46 er den nedeste i dette paste:
public static List getCNALatest5() {
List results = new ArrayList();
Connection con = openDatabase();
try{
Statement stmt = con.createStatement();
Metoden OpenDatabase() ser saadan her ud:
public static Connection openDatabase() {
Connection con = null;
try {
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost/" + database, username, password);
} catch (ClassNotFoundException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
} catch (SQLException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
return con;
}
Alting burde vaere i orden, jeg har brugt samme kode (eller tilsvarende tidligere). Kan nogen hjaelpe med hvorfor siger min Tomcat det nullpointer skrammel nu?
