472,373 Members | 2,110 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,373 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 10009
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...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.

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.