473,386 Members | 1,741 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,386 software developers and data experts.

Displaying db retrieved values in JSP

58
I m using MySql as back end n JSP as front end and the connectivity using JDBC. I ve to display a record retrieved from the db in the JSP page.
Expand|Select|Wrap|Line Numbers
  1. public void view_per_profile()
  2. {
  3. Connection con = null;ResultSet rs = null;
  4. CallableStatement cstmtm = null;
  5. try
  6. {
  7. Class.forName("org.gjt.mm.mysql.Driver").newInstance();
  8. System.out.println("Good to go");
  9. con = DriverManager.getConnection("jdbc:mysql://localhost/test1","root", "sivaji");
  10. cstmtm = con.prepareCall("{call viewp}");
  11. rs = cstmtm.executeQuery();
  12.  
  13. rs.first();
  14. title = cstmtm.getString(1);
  15. first_name = cstmtm.getString(2);
  16. middle_name = cstmtm.getString(3);
  17. last_name = cstmtm.getString(4);
  18. dob = cstmtm.getDate(5);
  19. email_id = cstmtm.getString(6);
  20. reg_no = cstmtm.getLong(7);
  21. day_num = cstmtm.getInt(8);
  22. sec_email = cstmtm.getString(9);
  23.  
  24. if(!con.isClosed())
  25. {
  26. cstmtm.close();
  27. System.out.println("Connected to MySQL server");
  28. }
  29. if(con != null)
  30. con.close();
  31. }
  32. catch(Exception e)
  33. {
  34. System.out.println(e);
  35. }
  36. }
  37.  
MySql Stored Procedure
Expand|Select|Wrap|Line Numbers
  1. create procedure viewp()
  2. begin
  3. select * from per where title = 'Ms';
  4. end
  5.  
I m getting the error java.sql.SQLException: No output parameters registered.Pls help me out...

Thanx in advance.................
Oct 24 '07 #1
3 1330
r035198x
13,262 8TB
I m using MySql as back end n JSP as front end and the connectivity using JDBC. I ve to display a record retrieved from the db in the JSP page.
Expand|Select|Wrap|Line Numbers
  1. public void view_per_profile()
  2. {
  3. Connection con = null;ResultSet rs = null;
  4. CallableStatement cstmtm = null;
  5. try
  6. {
  7. Class.forName("org.gjt.mm.mysql.Driver").newInstance();
  8. System.out.println("Good to go");
  9. con = DriverManager.getConnection("jdbc:mysql://localhost/test1","root", "sivaji");
  10. cstmtm = con.prepareCall("{call viewp}");
  11. rs = cstmtm.executeQuery();
  12.  
  13. rs.first();
  14. title = cstmtm.getString(1);
  15. first_name = cstmtm.getString(2);
  16. middle_name = cstmtm.getString(3);
  17. last_name = cstmtm.getString(4);
  18. dob = cstmtm.getDate(5);
  19. email_id = cstmtm.getString(6);
  20. reg_no = cstmtm.getLong(7);
  21. day_num = cstmtm.getInt(8);
  22. sec_email = cstmtm.getString(9);
  23.  
  24. if(!con.isClosed())
  25. {
  26. cstmtm.close();
  27. System.out.println("Connected to MySQL server");
  28. }
  29. if(con != null)
  30. con.close();
  31. }
  32. catch(Exception e)
  33. {
  34. System.out.println(e);
  35. }
  36. }
  37.  
MySql Stored Procedure
Expand|Select|Wrap|Line Numbers
  1. create procedure viewp()
  2. begin
  3. select * from per where title = 'Ms';
  4. end
  5.  
I m getting the error java.sql.SQLException: No output parameters registered.Pls help me out...

Thanx in advance.................
Perhaps you should go through a tutorial on procedures before you start using them. Why are you using a procedure for a a simple select statement anyway?
Oct 24 '07 #2
jith87
58
This is jus a prototype i m creating so that i get well versed in this concept....In the actual program its going to be multiple statements....
Oct 24 '07 #3
r035198x
13,262 8TB
This is jus a prototype i m creating so that i get well versed in this concept....In the actual program its going to be multiple statements....
Well you'll need to read a tutorial on procedures then. You don't get procedure results in a resultselt set like that.
Oct 24 '07 #4

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

Similar topics

1
by: Glen | last post by:
I have a list of beans that I retrieved from a database. These beans are all of the same class. Now I want to display these beans in a struts form so that the user can modify the data in the...
2
by: Rose | last post by:
Hi all, I'm a newbie to C# and .NET, so please be gentle! My limited background is in VBScript,ASP, and Access dbs. I need to retrieve data from a SQL server db (8.0) to be displayed in a...
3
by: rdc2732 | last post by:
I have a form with 10 numeric input fields (envision two rows and five columns). There is a column at the right for a total of each of the fields on each row. There is also a row with a...
4
by: Marc DVer | last post by:
As a simple example, say there is table 'namelist' with column 'names' as char(20). I would like to do something akin to: select namelist.names as mynames, left(mynames,2) as initials; In...
33
by: buss123 | last post by:
Hi all, combo box script code was working in IE perfectly with all modes but OnChange event was not working in FireFox(editable mode, if we select valuese that combo box values r...
1
by: ravindranathreddy | last post by:
Hi, I am trying to select a value from a table which data type is time stamp and in my select query i am checking for the condition, if the retrieved value is null then i am displaying it in the...
4
by: jith87 | last post by:
Hi, I ve retrieved values from MySql db. From the result set i ve used the getXXX() to get the values in seperate variables. Earlier i used getParameter() to get the values from JSP page to be...
1
by: ajos | last post by:
This may be very dumb question, but still...I am displaying a value in a input tag with the value shown as readonly... <input type=text size=18 maxlength=50 name="company" value=<%=companyCode %>...
14
by: ashraf02 | last post by:
i used a code from a website that allows you to display images. however everything works fine from storing the image to the database but it does not display the image. the following code is the...
2
by: chazzy69 | last post by:
I having trouble displaying information i have retrieved from an mysql database, i succesfully execute the SELECT query as shown below- $sql = "SELECT PCODE,LOCALITY,STATE FROM `postcode` WHERE...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...

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.