我尝试将Java程序连接到数据库和调用过程,没有语法错误或运行时错误,但是当编译器到达// st1并且我输入了第一个输入时,它会自动移到// st2(lastline ),它们之间的代码没有执行。因此,请帮助我解决此问题。
public static void main(String args[]) throws
SQLException,ClassNotFoundException
{
String driver = "oracle.jdbc.OracleDriver";
String url,pass;
url="jdbc:oracle:thin:@localhost:1521:prabhu";
pass = "sysdb1";
String user = "system";
Class.forName(driver);
Connection con = DriverManager.getConnection(url,user,pass);
CallableStatement cs = con.prepareCall("{call increase(?,?)}");
Scanner sc = new Scanner(System.in); //st1
Scanner sname = new Scanner(System.in);
System.out.println("enter employee id and name whose salary you want to increase");
int id=sc.nextInt();
String name = sc.nextLine();
cs.setInt(1, id);
cs.setString(2, name);
cs.execute();
System.out.println("salary increased"); //st2