Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2010
    Posts
    87
    Rep Power
    0

    Default 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.

    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();
                }
            }
        }
    }
    OUTPUT:

    b
    4
    Translation: for
    Translation: fore
    Translation: four

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    18

    Default 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...:)

Similar Threads

  1. One process open multiple threads on multiple CPUs
    By kfcnhl in forum Threads and Synchronization
    Replies: 2
    Last Post: 12-12-2011, 08:27 AM
  2. Java JDBC - Display Multiple Query Results in one GUI
    By nov072008 in forum AWT / Swing
    Replies: 5
    Last Post: 10-06-2011, 05:03 PM
  3. Returning multiple results in JDBC
    By mDennis10 in forum New To Java
    Replies: 7
    Last Post: 08-23-2011, 03:38 PM
  4. multiple Data from Jsp that having same name of multiple input tage to servlet
    By rahul9323.2007@gmail.com in forum Advanced Java
    Replies: 0
    Last Post: 07-29-2011, 01:00 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •