Can't Get Multiple Results...
Hello All.
The problem I am having is that I can't get multiple query results when I search my database. For example... I search my DB for 'b' and '4', the query then returns all possibilities of new words that can be made when the respective results are put together... E.g. 'be+for' 'be+four' 'be+fore' .
(I know the split section of my code isn't really doing anything at the moment, I was just trying to include when I was trying to solve the same problem another way).
Thanks for any help.
Code:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class PreparedStatementParameter {
public static void main(String[] args) {
Connection conn = null;
PreparedStatement prepStmt = null;
ResultSet rs = null;
String smsWord = "b.4”";
String[] smsWordSplits = smsWord.split("\\.");
for(String smsWord1: smsWordSplits){
System.out.println(smsWord1);
}
try {
Class.forName("org.sqlite.JDBC");
conn = DriverManager.getConnection("jdbc:sqlite:C:\\projectdb.sqlite");
String sqlStmt = "SELECT English FROM projectdb WHERE SMS = ?";
prepStmt = conn.prepareStatement(sqlStmt);
prepStmt.setString (1, "4");
rs = prepStmt.executeQuery();
while (rs.next()) {
String id = rs.getString("English");
System.out.println("Translation: " +id+ "" );
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (rs != null)
rs.close();
} catch (SQLException e) {
e.printStackTrace();
}
try {
if (prepStmt != null)
prepStmt.close();
} catch (SQLException e) {
e.printStackTrace();
}
try {
if (conn != null)
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
OUTPUT:
b
4”
Translation: for
Translation: fore
Translation: four
Re: Can't Get Multiple Results...
See my post in the JDBC thread.
That might help clear up some stuff in your mind.
...or confuse it even more...:)