I am new to database and recently started writing test cases for H2 database. I want to know how to test a stored procedure in Eclipse. I have seen the following:
ht
There is no stored procedure and sql userdefined function in H2 database instead of that we use java methods and create a alias to refer that.We can call that methods using alias.
Below is a simple example:**
DROP ALIAS IF EXISTS MYFUNCTION;
CREATE ALIAS MYFUNCTION AS $$
String getTableContent(java.sql.Connection con) throws Exception {
String resultValue=null;
java.sql.ResultSet rs = con.createStatement().executeQuery(
" SELECT * FROM TABLE_NAME");
while(rs.next())
{
resultValue=rs.getString(1);
}
return resultValue;
}
$$;