I am working with postgresql procedures and trying to call a procedure from my JDBC program. But getting runtime exception saying procedure doesn't exist eventhough I cross-checked and verified that the procedure name is correct. This is what I am doing
CallableStatement cs = connection.prepareCall("{call proc1()}");
cs.executeUpdate();
And here's my proc1 procedure
create or replace procedure proc1()
as
begin
insert into employee_info values(1,'johnny','1111',43);
-----
end
This is what the output is
Connection Failed! ERROR: function proc1() does not exist
Hint: No function matches the given name and argument types. You might need to add explicit type casts.
I dont understand why its not working eventhough proc1() exists in database. And what should i Cast?
Finally, I got the solution. The main problem was with JDBC Driver which I downloaded from the official website. I was using the postgresql driver. I dont know what's wrong with it but It seems like it is not supporting proedures. So I switched to EnterpriseDB(EDB) driver. Now the same program works fine and procedures are getting executed.
I just made these changes
1)Changing Driver
2)Changing Driver Class url from "org.postgresql.Driver"
to "com.edb.Driver"
3)Dabase url "jdbc:postgresql://host:port/db
to "jdbc:edb://host:port/db"
That's all. Now the procedures works too.