开发者

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.Prepared开发者_StackOverflowStatement 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.*;


  1. the 2 param method in PreparedStatement for setDate takes a Calendar, not a String
  2. the 2 param method in PreparedStatement for setDate takes a Calendar, not a String,
  3. the 2 param method for setInt takes two ints, not and int and a String.
  4. you already have another field in your main method called 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. The API-Doc of PreparedStatement will show you, that there is a Method setString(int,String) which will take a String as second Parameter.

http://download.oracle.com/javase/1.4.2/docs/api/java/sql/PreparedStatement.html

Maybe you wanted to call ps.setInt(2, 88349);

There ist a valiable called e already defined in that scope.

try{
    // some Code
    try{
        // some more coe
    } catch (Exception e){}
                      ^^^
              Compiling Error
} catch (Exception e){}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜