java - How to get integer value from JTextField of Swing? -


how integer value jtextfield of swing string value via gettext() method?

try {         string sql = "insert employeeinfo   (username,password,obtainmark) values(?,?,?)";         pst = conn.preparestatement(sql);         pst.setstring(1, txt_username.gettext());         pst.setstring(2, txt_password.gettext());         pst.setint(3, txt_obtainmark.gettext());         pst.execute();          joptionpane.showmessagedialog(null, "data inserted");     } catch (exception e) {          joptionpane.showmessagedialog(null, e);     } 

i not able insert integer data type value jtextfield, able insert string or varchar type data.

you can integer.parseint(string) integer value.

pst.setint(interger.parseint(txt_obtainmark.gettext())); 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -