Advertisement
Guest User

Untitled

a guest
May 21st, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. String a = JOptionPane.showInputDialog(null, "What flavor do you want to add?");
  2. String sql = "INSERT INTO tblFlavor values('+a+')";
  3.  
  4. try {
  5.  
  6. Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
  7.  
  8. String connectionURL = "jdbc:sqlserver://localhost:1433;databaseName=finalsTableDB;user=admin;password = password";
  9.  
  10. Statement st = con.createStatement();
  11.  
  12. int i = st.executeUpdate(sql);
  13. if (i > 0) {
  14. JOptionPane.showMessageDialog(null, "Successfully Added!!");
  15. }
  16. } catch (Exception e) {
  17. JOptionPane.showMessageDialog(null, "Failed To Add!!!");
  18. }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement