By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,654 Members | 1,517 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,654 IT Pros & Developers. It's quick & easy.

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

P: 3
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 :

Expand|Select|Wrap|Line Numbers
  1. 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:

Expand|Select|Wrap|Line Numbers
  1. String pilote = "com.mysql.jdbc.Driver";
  2.                 jComboBoxType.addItemListener(new ItemState());
  3.         jComboBoxMenaces.addItemListener(new ItemState());
  4.  
  5.               try {
  6.  
  7.  
  8.                  Class.forName(pilote); 
  9.  
  10. Connection connexion = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root"," "); 
  11.  
  12. Statement instruction = connexion.createStatement(); 
  13.  
  14.             String a=jTextFieldNom.getText();
  15.  
  16.  
  17.             String SQL = "select description from table where nomcol="+a+";"; 
  18.             ResultSet rs = instruction.executeQuery(SQL);
  19.             instruction = connexion.createStatement();
  20.  
  21.  
  22.             int rowsEffected = instruction.executeUpdate(SQL);
  23.             jTextArea1.append(rs.getString("description"));                                    
  24.  
  25. }
  26. ...... //bloc catch 
Apr 9 '12 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.