Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Framework inputDialogBox
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Manash Kumar
inputDialogBox
1 Answer(s)      3 years and 7 months ago
Posted in : Framework


how to pass sql query from inputDialogbox and find the data from database plz help me


Advertisement
View Answers

March 25, 2011 at 3:01 PM


import java.sql.*;
import javax.swing.*;
class  Retrieve{
public static void main(String[] args){
    try{
           Class.forName("com.mysql.jdbc.Driver");
           Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
           Statement st=con.createStatement();
           String query=JOptionPane.showInputDialog(null,"Enter query");
           ResultSet rs=st.executeQuery(query);
           String name="",address="";
           if(rs.next()){
              System.out.println("Name: "+rs.getString("name"));
               System.out.println("Address: "+rs.getString("address"));
           }
    }
    catch(Exception e){}

    }
}


Related Tutorials/Questions & Answers:
inputDialogBox
inputDialogBox  how to pass sql query from inputDialogbox and find the data from database plz help me
 

 

 

DMCA.com