Hello all,
I have the following code.
Connection connection = getMySQLConnection();
try {
Statement st = connection.createStatement();
String SQL = "SELECT ID, NAME FROM STUDENT WHERE ID=5";
ResultSet rs = st.executeQuery(SQL);
System.out.println("SQL =" + SQL);
while (rs.next()) {
// do something...
}
} catch (SQLException se) {
se.pringStackTrace();
}
From my J2EE appliation, the query doesn't return anything, and it doesn't enter the while() loop.
But, if I run the same query from within my MySQL, I get results alright. I don't know what I am doing wrong?
mysql> SELECT ID, NAME FROM MY_TABLE WHERE id=5;
+------------+-----------------+
| ID | NAME |
+------------+-----------------+
| 5 | JOHN DOE |
+------------+-----------------+
1 row in set (0.01 sec)
Can someone please advise? Thanks in advance.