I want to execute a selected item in palette GUI using Java NetBeans. I intention to select one or many items first, then execute the button. Here is the code:
User user = status.getUser();
Date dated = status.getCreatedAt();
PreparedStatement stmt = null;
Connection conne = null;
try {
Class.forName("com.mysql.jdbc.Driver");
jTextArea1.append("Connecting to database... " + "\n");
conne = DriverManager.getConnection("jdbc:http://mysqllocalhostuseUnicode=true&characterEncoding=UTF-8", "root", "");
jTextArea1.append(status + "\n");
jTextArea1.append("Inserting records into the table..." + "\n");
stmt = conne.prepareStatement("set names 'utf8'");
stmt.execute();
stmt = conne.prepareStatement("set character set utf8");
stmt.execute();
stmt = conne.prepareStatement("INSERT INTO japantweet(ID,date,name,statusLocation,text,source) VALUES (?,?,?,?,?,?)");
stmt.setInt(1, (int) status.getId());
stmt.setString(2, getTimeStamp());
stmt.setString(3, status.getUser().getScreenName());
stmt.setString(4, user.getLocation());
stmt.setString(5, status.getText());
stmt.setString(6, status.getSource());
stmt.executeUpdate();
jTextArea1.append("this record inserted!" + "\n");
jTextArea1.append("=======================" + "\n");
} catch (SQLException se) {
se.printStackTrace();
} catch (final Exception e) {
e.printStackTrace();
}
And this is the interface:
Many thanks for any comment!
Aucun commentaire:
Enregistrer un commentaire