473,847 Members | 1,743 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to call mysql stored procedures in java

5 New Member
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.Insta ntiationExcepti on; must be caught or declared to be thrown
Class.forName ("com.mysql.jdb c.Driver").newI nstance();
I need code sample along with connection string.please.. ..

My codings here

CallableStateme nt proc = null;


try
{
String url = "jdbc:mysql ://localhost/Test_DB";
Class.forName ("com.mysql.jdb c.Driver").newI nstance();
Connection conn = DriverManager.g etConnection (url, "root", "");

proc = conn.prepareCal l("{ call sp_InsertEmploy ee('"+EmployeeC ode+"','"+Emplo yeeName+"','"+D esignation+"', '"+Department+" ') }");
proc.execute();
proc.close();
conn.close();
}
catch (SQLException e)
{

}
Sep 28 '06 #1
1 10125
r035198x
13,262 MVP
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.Insta ntiationExcepti on; must be caught or declared to be thrown
Class.forName ("com.mysql.jdb c.Driver").newI nstance();
I need code sample along with connection string.please.. ..

My codings here

CallableStateme nt proc = null;


try
{
String url = "jdbc:mysql ://localhost/Test_DB";
Class.forName ("com.mysql.jdb c.Driver").newI nstance();
Connection conn = DriverManager.g etConnection (url, "root", "");

proc = conn.prepareCal l("{ call sp_InsertEmploy ee('"+EmployeeC ode+"','"+Emplo yeeName+"','"+D esignation+"', '"+Department+" ') }");
proc.execute();
proc.close();
conn.close();
}
catch (SQLException e)
{

}
what happens when you add the catch InstantiateExce ption 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
9107
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 comparison to oracle? We are seriously considering migrating our multi-processor oracle system to mysql to save on licensing costs, and would need several features that mysql may or may not have:
3
1924
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, @dummyTaxId int) RETURNS @retTable TABLE (path varchar(2048), parent_id int, category_id int,
7
8409
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
2093
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 makes sense. One of my favorites things about MS SQL is being able to use the Enterprise Manager as a GUI in constructing VIEWS that I later turn into stored procedures. EM makes it super simple to link tables and create a query. It basically...
14
2122
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? http://developers.slashdot.org/developers/03/12/19/1628241.shtml?tid=108&tid=126&tid=137&tid=156&tid=198 Cheers T.
175
11545
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 think is PostgreSQL would have less USP's (Uniqe Selling Points
13
4817
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, $statement); Result: PHP Warning: odbc_exec(): SQL error: CLI0119E Unexpected system failure.
15
1697
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 worried about support/maintenance issues going forward since I no little J2EE (have some Java) - but am no longer able to rely on the J2EE developer going forward. I am now seriously considering using WAMP, but I am not yet terribly convinced...
2
6126
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 is shut down by Windows. When I make changes to my procedure, it doesn't seem to always change what is being executed. Furthermore, sometimes the procedure just disappears from my database. I am starting to think that the stored procedure...
0
9887
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10983
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10648
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10341
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9485
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7883
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7056
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5911
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4119
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.