I am attempting to print some results from an SQL statement inside of Java and I am receiving an error saying these variables need to be initialized but I'm not sure how to go about doing this other than setting them to null which isn't what I want to do here, my error is when attempting to close st, rs and con, I am prompted to initialize the variables but this just sets them to null, here is my code so far:
public static void copyFolder(File src, File dest)
throws IOException {
Connection con;
Statement st;
ResultSet rs;
try {
con = DriverManager.getConnection("removed as it houses sensitive data");
st = con.createStatement();
String s = "SELECT Code FROM dbo.\"FK Facades$Dimension Value\" WHERE [Dimension Code] = 'PROJECT'";
rs = st.executeQuery(s);
while (rs.next()) {
rs.getString(1);
System.out.print(rs);
}
} catch (Exception e) {
System.out.println("No connectarino");
} finally {
try {
st.close();
rs.close();
con.close();
} catch (Exception e) {
System.out.println("No");
}
}
}