Reputation:
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.*;
Upvotes: 0
Views: 1699
Reputation: 16060
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){}
Upvotes: 0
Reputation: 39475
PreparedStatement
for setDate
takes a Calendar, not a StringPreparedStatement
for setDate
takes a Calendar, not a String,setInt
takes two int
s, not and int and a String.main
method called e
. Upvotes: 1