Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

How to save MySQL query result?

mysql variable type mysql_query

  • Please log in to reply
No replies to this topic

#1 alex1

alex1

    CC Resident

  • Advanced Member
  • PipPipPipPip
  • 97 posts

Posted 05 March 2012 - 07:34 AM

Hello...My question may be kinda silly,but I have lost my mind after few hours of coding...
I have this code:

String query="SELECT * " + "FROM cars "+ "WHERE ID > "+ "'" + strLine + "'";
                                      ResultSet result = select.executeQuery(query);
                                     while (result.next()) {
                                    	 //do nothing 4 now
                                      }
                                     result.beforeFirst();
                        if(result.next()){
                        	
                        	//DISPLAY A MESSAGE
                        }else{
                                        //do nothing 4 now
                        }
                                     select.close();
                        dbConn.close();

strLine is a number saved in a txt file (in case you're curious) :)

Now,after the query is executed,I need to save the result in the file...Here is my problem... How am I supposed to pass the result to a variable?
I tried this:

String str1 = result.next();

As I expected it did not worked.The anly variable type I can use is boolean wich can't help me...

Do you guys have any ideas,how to save the query result?

Warm thanks for any replay!!!!

Edit
Ok..Now I think that I'm not passing trought all the IDs in the table... :D
  • 0





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download