Hi I’m trying to connect to and SQLite table in java and it only outputs data from one method in the compiler output window code is below working method it commented to show which one is printing out the data please could you help.
//working methord which outputs data
@Override
public String getReplyTimestamp(int RPLYID) {
try {
Class.forName("org.sqlite.JDBC");
Connection conn = DriverManager.getConnection("jdbc:sqlite:C:\\Users\\Matt\\Documents\\message.sqlite");
Statement stmt = conn.createStatement();
String query = "SELECT * FROM MSG"; //Change message to relevent declaration
ResultSet rs = stmt.executeQuery(query);
while (rs.next()) {
System.out.println(rs.getString("MSG")+" "+rs.getString("URL"));
}
conn.close();
} catch (SQLException ex) {
Logger.getLogger(DBAccessImpl.class.getName()).log(Level.SEVERE, null, ex);
} catch (ClassNotFoundException ex) {
Logger.getLogger(DBAccessImpl.class.getName()).log(Level.SEVERE, null, ex);
}
return "getReplyTimestamp";
}
//Methoed which does not print
@Override
public String getReply(int RPLYID) {
try {
Class.forName("org.sqlite.JDBC");
Connection conn = DriverManager.getConnection("jdbc:sqlite:C:\\Users\\Matt\\Documents\\message.sqlite");
Statement stmt = conn.createStatement();
String query = "SELECT * FROM RPLY"; //Change message to relevent declaration
ResultSet rs = stmt.executeQuery(query);
while (rs.next()) {
System.out.println(rs.getString("RPLY")+" "+rs.getString("TSTAMP"));
}
conn.close();
} catch (SQLException ex) {
Logger.getLogger(DBAccessImpl.class.getName()).log(Level.SEVERE, null, ex);
} catch (ClassNotFoundException ex) {
Logger.getLogger(DBAccessImpl.class.getName()).log(Level.SEVERE, null, ex);
}
return "getReply";
}
Aucun commentaire:
Enregistrer un commentaire