I want to get doktor[0], doktor[1], secilenBolum from RandevufiltreSorgu.java. I created object of RandevufiltreSorgu class in randevusec. But when I run the query, I am not able to obtain the values I want. There is no inheritance in use. What can I do?
public class randevusec {
Connection conn = null;
PreparedStatement ps = null;
ResultSet rs = null;
public ResultSet saatler() throws SQLException, Exception {
randevufiltreSorgu nesne = new randevufiltreSorgu();
try {
Class.forName("org.postgresql.Driver");
conn = DriverManager.getConnection("jdbc:postgresql://localhost:5432/tipmerkezivt", "postgres", "2569");
ps = conn.prepareStatement(
"WITH Q1 AS(\n" + " select * from doktor natural join bolum where dr_adi='" + nesne.doktor[0]
+ "' and dr_soyadi='" + nesne.doktor[1] + "' and bolum.b_adi='" + nesne.secilenBolum + "'\n"
+ " )\n" + " select cs_saat from doktorun_programi natural join Q1\n" + " ",
ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
rs = ps.executeQuery();
return rs;
} catch (Exception e) {
throw new Exception("Bağlantı başarısız!");
}
finally {
conn.close();
}
}
}
It is very hard to understand your code because it is mostly in foreign language, but what you can do is when you construct doktor[0] and doktor[1], put the keyword public static before them.