how can I display data into my Jtextarea from my data base Mysql

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • norman2000
    New Member
    • Mar 2012
    • 3

    how can I display data into my Jtextarea from my data base Mysql

    hi,
    I have problem when I try to displa data from my database mysql to my jTextarea,when I compile I have an error exception like :

    Code:
    SQL Exception: java.sql.SQLException: Can not issue SELECT via executeUpdate()
    I have used a select query from my table where the name is the name writed in my jTextfield,this is my code,I hope that some one help me because I don't know how to reesolve the problem and thanks:

    Code:
    String pilote = "com.mysql.jdbc.Driver";
                    jComboBoxType.addItemListener(new ItemState());
            jComboBoxMenaces.addItemListener(new ItemState());
            
                  try {
    
                      
                     Class.forName(pilote); 
    
    Connection connexion = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root"," "); 
    
    Statement instruction = connexion.createStatement(); 
     
                String a=jTextFieldNom.getText();
       
                
                String SQL = "select description from table where nomcol="+a+";"; 
                ResultSet rs = instruction.executeQuery(SQL);
                instruction = connexion.createStatement();
                
                
                int rowsEffected = instruction.executeUpdate(SQL);
                jTextArea1.append(rs.getString("description"));                                    
                    
    }
    ...... //bloc catch
Working...