469,580 Members | 1,910 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,580 developers. It's quick & easy.

How to call mysql stored procedures in java

hai friends
i am new to java and mysql.i have created stored procedures in mysql.Now i want to call that stored procedures in java.All works fine.but it show the following error.

unreported exception java.lang.InstantiationException; must be caught or declared to be thrown
Class.forName ("com.mysql.jdbc.Driver").newInstance();
I need code sample along with connection string.please....

My codings here

CallableStatement proc = null;


try
{
String url = "jdbc:mysql://localhost/Test_DB";
Class.forName ("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection (url, "root", "");

proc = conn.prepareCall("{ call sp_InsertEmployee('"+EmployeeCode+"','"+EmployeeNa me+"','"+Designation+"', '"+Department+"') }");
proc.execute();
proc.close();
conn.close();
}
catch (SQLException e)
{

}
Sep 28 '06 #1
1 9857
r035198x
13,262 8TB
hai friends
i am new to java and mysql.i have created stored procedures in mysql.Now i want to call that stored procedures in java.All works fine.but it show the following error.

unreported exception java.lang.InstantiationException; must be caught or declared to be thrown
Class.forName ("com.mysql.jdbc.Driver").newInstance();
I need code sample along with connection string.please....

My codings here

CallableStatement proc = null;


try
{
String url = "jdbc:mysql://localhost/Test_DB";
Class.forName ("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection (url, "root", "");

proc = conn.prepareCall("{ call sp_InsertEmployee('"+EmployeeCode+"','"+EmployeeNa me+"','"+Designation+"', '"+Department+"') }");
proc.execute();
proc.close();
conn.close();
}
catch (SQLException e)
{

}
what happens when you add the catch InstantiateException block near the SQLException?
Note when catching exceptions try do something not to leave the catch block blank. It makes it easier to debug
Sep 28 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

133 posts views Thread by jonathan | last post: by
3 posts views Thread by slash | last post: by
7 posts views Thread by Michael C# | last post: by
175 posts views Thread by Sai Hertz And Control Systems | last post: by
13 posts views Thread by Larry Menard | last post: by
15 posts views Thread by Susan Baker | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.