sql server - "java.util.Scanner[delimiters=\p{javaWhitespace}+]" Error in JDBC program -


i have written jdbc application has function called "updatestudent," takes studentid parameter , receives user input student's variables changed to. stored procedure works fine within sql server, running things java results in string varaibles being changed value "java.util.scanner[delimiters=\p{javawhitespace}+]". however, integer values not affected, , updated correctly. believe issue has implementation of scanner in java, since works fine within sql server itself. below function updatestudent main:

public static void updatestudent() {     system.out.print("\n please enter id of current student wish update");     system.out.print("\n==>");      student student = new student();      @suppresswarnings("resource")      scanner insertstudentid = new scanner(system.in);     int passedstudentid = insertstudentid.nextint(); //program starts counting @ zero, starts displaying @ 1      system.out.print("\n enter new value firstname \n ==> ");     @suppresswarnings("resource")     scanner insertedfirstname = new scanner(system.in);     insertedfirstname.nextline();             string passedfirstname = insertedfirstname.tostring();     student.setmfirstname(passedfirstname);      system.out.print("\n enter new value lastname \n ==> ");     @suppresswarnings("resource")     scanner insertedlastname = new scanner(system.in);     insertedlastname.nextline();     string passedlastname = insertedlastname.tostring();     student.setmlastname(passedlastname);      system.out.print("\n enter new value num \n ==> ");     @suppresswarnings("resource")     scanner insertednum = new scanner(system.in);     int passednum = insertednum.nextint();     student.setmnum(passednum);      student.updatestudent(passedstudentid, passedfirstname, passedlastname, passednum);      scanner kb = new scanner(system.in);     system.out.print("\nhit enter continue...");     string discard = kb.nextline();             } 

here function updatestudent student class well:

public void updatestudent(int studentid, string lastname, string firstname, int num)  {      connection con = dbconnect();     callablestatement cs = null;     resultset rs = null;     //int studentid1=0;     int returnval=0;     try {         cs = con.preparecall("{? = call updatestudent (?,?,?,?)}");         cs.registeroutparameter(1, returnval);         cs.setint(2, studentid);    //changed setint registeroutparameter                                        //when changed setint registeroutparameter                                        //error: formal parameter "@studentid" not declared                                      //as output parameter, actual parameter passed in requested output.         cs.setstring(3, firstname);                     cs.setstring(4, lastname);                   cs.setint(5,num);          rs = cs.executequery();        // cs.executequery();      } catch (sqlexception e) {         e.printstacktrace();     } {         if (rs != null) try { rs.close(); } catch(exception e) {}         if (cs != null) try { cs.close(); } catch(exception e) {}         if (con != null) try { con.close(); } catch(exception e) {}     }   } 

i appreciate pointers why getting error. seems compiling , running fine, think might displaying results incorrectly somehow.

scanner.tostring() returns string representation of scanner not string in stream. string representation of scanner contains information may useful debugging.

if want use scanner input, use nextline(), example:

string passedfirstname = insertedfirstname.nextline(); 

besides, need 1 scanner object.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -