I'm a beginner of JDBC and mySQL5.
I had created a statement for the JDBC as shown below:
try{
Class.forName("com.mysql.jdbc.Driver")…
// Establish the connection
c = DriverManager.getConnection
("jdbc:mysql://localhost/dbanimals", "root", "");
stmt1 = c.createStatement();
String sql1 = "SELECT * FROM animals WHERE " +
"word = '" + txtSearch.getText() + "'";
rs1 = stmt1.executeQuery(sql1);
How should i create a if and else statement for JDBC :
if a word from a Jtextfield (txtSearch.getText()) match with mySQL database field, it will execute the (rs1 = stmt1.executeQuery(sql1)

I did try out other methods but it didn't works
This is the mySQL database:
+----+------+-------------------------…
| no | word | explanation | num_of_searches |
+----+------+-------------------------…
| 1 | Bee | An insect that produces honey. | 0 |
| 2 | Dog | An animal that bark. | 2 |
+----+------+-------------------------…
Thanks in advanced
This post has been edited by [email protected]: 05 September 2009 - 06:09 AM