[英]Error in compilation of java code
shilps.java:198: cannot find symbol
symbol : method setDate(int,java.lang.String)
location: interface java.sql.PreparedStatement
ps.setDate(2, "2010-05-31");
^
shilps.java:231: cannot find symbol
symbol : method setDate(int,java.lang.String)
location: interface java.sql.PreparedStatement
ps.setDate(1, "2010-05-31");
^
shilps.java:232: setInt(int,int) in java.sql.PreparedStatement cannot be applied to
(int,java.lang.String)
ps.setInt(2, "88349");
^
shilps.java:293: e is already defined in main(java.lang.String[])
}catch(Exception e){
^
6 errors
Why the error is occurring? 为什么会发生错误? I have included: 我包括:
import java.util.*;
import java.io.*;
import java.sql.*;
PreparedStatement
for setDate
takes a Calendar, not a String setDate
PreparedStatement
的2参数方法采用日历,而不是字符串 PreparedStatement
for setDate
takes a Calendar, not a String, setDate
PreparedStatement
的2参数方法采用日历,而不是字符串, setInt
takes two int
s, not and int and a String. setInt
的2参数方法采用两个int
,而不是int和一个String。 main
method called e
. 您的main
方法中已经有另一个名为e
字段。 The compiler tells you everything you needd to know: 编译器会告诉您所有您需要了解的内容:
setInt(int,int) in java.sql.PreparedStatement cannot be applied to (int,java.lang.String)
This means, you are passing a Value of Type String
to a methods witch needs a int
. 这意味着,您正在将String
类型的Value传递给需要int
的方法。 The API-Doc of PreparedStatement will show you, that there is a Method setString(int,String)
which will take a String as second Parameter. PreparedStatement的API文档将向您显示,有一个方法setString(int,String)
,它将String作为第二个参数。
http://download.oracle.com/javase/1.4.2/docs/api/java/sql/PreparedStatement.html http://download.oracle.com/javase/1.4.2/docs/api/java/sql/PreparedStatement.html
Maybe you wanted to call ps.setInt(2, 88349);
也许您想调用ps.setInt(2, 88349);
There ist a valiable called e
already defined in that scope. 在该范围内已经定义了一个名为e
的变量。
try{
// some Code
try{
// some more coe
} catch (Exception e){}
^^^
Compiling Error
} catch (Exception e){}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.