473,326 Members | 2,732 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

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 10091
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

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

Similar topics

133
by: jonathan | last post by:
hey all, I realize that this question might pop up from time to time, but I haven't seen it a while and things might of changed, so - Right now (July 2004) how does mysql stand up in...
3
by: slash | last post by:
Hi , Im new to MySql and i have no idea how to convert a sql server user defined function to MySql. Can any one help me.. CREATE FUNCTION ChildCategories (@categoryId int, @taxId int,...
7
by: Michael C# | last post by:
Is it possible to create Dynamic SQL queries in MySQL, like in SQL Server? i.e., the EXECUTE command or sp_executesql stored procedure in SQL Server. TIA
3
by: Ben | last post by:
Dear MySQL experts, I have a website that is using MS SQL Server 2000 with ASP scripting. I want to switch over to MySQL, but I'm just sticking my toes in the water at the moment to see if it...
14
by: Tony | last post by:
Can someone a little more clever than I (which means just about anyone on this list) tell me what the implications/benefits are of this are please? ...
175
by: Sai Hertz And Control Systems | last post by:
Dear all, Their was a huge rore about MySQL recently for something in java functions now theirs one more http://www.mysql.com/doc/en/News-5.0.x.html Does this concern anyone. What I...
13
by: Larry Menard | last post by:
Test code: $dbconn = odbc_connect($dbname, $username, $password); $path = "C:\Temp\myJar.jar"; $statement = "CALL SQLJ.INSTALL_JAR('file://$path', 'myJarId')"; $result = odbc_exec($dbconn,...
15
by: Susan Baker | last post by:
Note: This is different from previous post. I am coming from a C/C++ background. I have a frontend (written in C#), my backend was originally meant to be a J2EE application with PostGreSQL. I am...
2
by: bshumsky06 | last post by:
Hi, I am trying to create stored procedures in MySQL. Does anyone have a suggestion on a good IDE to use. I have been working with the MySQL Query Browser but it generates errors very often and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.