Results 1 to 2 of 2
Thread: Can't Get Multiple Results...
- 01-11-2012, 04:08 AM #1
Member
- Join Date
- Nov 2010
- Posts
- 87
- Rep Power
- 0
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.
OUTPUT:Java 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(); } } } }
b
4”
Translation: for
Translation: fore
Translation: four
- 01-11-2012, 10:04 AM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
Similar Threads
-
One process open multiple threads on multiple CPUs
By kfcnhl in forum Threads and SynchronizationReplies: 2Last Post: 12-12-2011, 08:27 AM -
Java JDBC - Display Multiple Query Results in one GUI
By nov072008 in forum AWT / SwingReplies: 5Last Post: 10-06-2011, 05:03 PM -
Returning multiple results in JDBC
By mDennis10 in forum New To JavaReplies: 7Last Post: 08-23-2011, 03:38 PM -
multiple Data from Jsp that having same name of multiple input tage to servlet
By rahul9323.2007@gmail.com in forum Advanced JavaReplies: 0Last Post: 07-29-2011, 01:00 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks