database : mysql
here
java callable statement program (in eclipse):
static Connection con = null;
static CallableStatement st = null;
public static void main(
String[] args) {
// TODO Auto-generated method stub
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
//Connection
con = DriverManager.getConnection("jdbc:mysql://localhost/orcl","root","pspl");
System.out.println("Connected");
//Statement st = null;
st=(CallableStatement) con.prepareCall("{call ins(?,?)}");
//((CallableStatement) st).setInt(1,121);
//((CallableStatement) st).setString(2,"harish");
st.setInt(1,121);
st.setString(2,"harish");
st.execute();
}
catch(Exception e)
{
e.printStackTrace();
}
and here
mysql> create procedure ins(a IN int, b IN varchar)
-> as
-> begin
-> insert into emp values(a,b);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'IN in
t, b IN varchar)
as
begin
insert into emp values(a,b)' at line 1
why it is getting error? and tell me how to execute these function?