Jeg får denne meddelelse når jeg kører test
java.lang.Error: Unresolved compilation problem:
Unhandled exception type java.sql.SQLException
at java.lang.reflect.Constructor.newInstance(Native Method)
at NyDBK.testSelect(NyDBK.java:21)
at NyDBK.<init>(NyDBK.java:18)
at Test.main(Test.java:13)
Exception in thread "main"
import java.io.IOException;
import java.sql.*;
public class NyDBK{
private Connection conn;
Statement stmt = null;
ResultSet rs = null;
public NyDBK(String input) {
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:
mysql://localhost/");
}
catch (Exception e) {
System.out.println("Kunne ikke initialisere JDBC connection. " + e);
}
testSelect();
}
public void testSelect(){
stmt = conn.createStatement(); // her laver eclipse røde streger
}
}
stmt = conn.createStatement();
I denne linie laver eclipse røde streger
Hvorfor???