Hi,
Is there a way to call stores procedures and database functions on server side ? Basically we want to write no queries, instead stored procedures will be helpful.
Any links or recipes ?
Thanks.
Calling stored procedures from server side !
Re: Calling stored procedures from server side !
Hi,
we don't have specific recipes because stored procedures differ based on the database of your choice.
In a nutshell you just need to use JDBC directly instead of our DBManager API. In other words you can obtain the database connection from the DBManager:
Then call your stored procedures with a code like this:
The example is taken from this article from Oracle:
https://docs.oracle.com/javase/tutorial ... dures.html
which illustrates how to create and use stored procedures in Java.
Finally make sure to handle the life cycle of the database connection correctly using a try/catch/finally block to trap exceptions and close the connection at the end of the query process.
See the "Handling Exceptions" section here:
http://docs2x.smartfoxserver.com/Develo ... se-recipes
hope it helps
we don't have specific recipes because stored procedures differ based on the database of your choice.
In a nutshell you just need to use JDBC directly instead of our DBManager API. In other words you can obtain the database connection from the DBManager:
Code: Select all
connection = dbManager.getConnection();
Then call your stored procedures with a code like this:
Code: Select all
cs = connection.prepareCall("{call SHOW_SUPPLIERS()}");
ResultSet rs = cs.executeQuery();
while (rs.next()) {
String supplier = rs.getString("SUP_NAME");
String coffee = rs.getString("COF_NAME");
System.out.println(supplier + ": " + coffee);
}
The example is taken from this article from Oracle:
https://docs.oracle.com/javase/tutorial ... dures.html
which illustrates how to create and use stored procedures in Java.
Finally make sure to handle the life cycle of the database connection correctly using a try/catch/finally block to trap exceptions and close the connection at the end of the query process.
See the "Handling Exceptions" section here:
http://docs2x.smartfoxserver.com/Develo ... se-recipes
hope it helps
Re: Calling stored procedures from server side !
Hi,
Thanks for the reply !
I will try it out and will post results thanks.
Thanks for the reply !
I will try it out and will post results thanks.
Re: Calling stored procedures from server side !
It is working, thanks.
Who is online
Users browsing this forum: No registered users and 48 guests