Retriving data from sql server using Java/jsp

Hi,

I want help on getting data from sql server to Java/JSP page.  I am new to Java/jsp, and need some help with some sample code.

I have a stored proc. [getemployee] which is retrieving FirstName,LastName,EmailAddress. I need to use this stored proc on Java/jsp to show details on jsp page.

Thank you so much for help!
r_pat72Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MishaProgrammerCommented:
No, it is not possible to connect to SQL Server 'directly' from browser-JavaScript.
JavaScript can "speak" HTTP and WebSockets, but SQL Server "speaks" TDS.
If you use something like ASP NET MVC, you can do it on the server side.

This is example on Java to call stoder procedure:
String SPsql = "EXEC <sp_name> ?,?";   // for stored proc taking 2 parameters
Connection con = SmartPoolFactory.getConnection();   // java.sql.Connection
PreparedStatement ps = con.prepareStatement(SPsql);
ps.setEscapeProcessing(true);
ps.setQueryTimeout(<timeout value>);
ps.setString(1, <param1>);
ps.setString(2, <param2>);
ResultSet rs = ps.executeQuery();

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Wayne BarronAuthor, Web DeveloperCommented:
I am an ASP Classic and ASP.NET (VB) developer, so, the only thing I can suggest is the following page for an example.
I, however, have not tested it out.
But, you should be able to learn something from it, to get yourself going.
This is using the JSP to connect and retrieve data from a SQL Server.
http://www.java-samples.com/showtutorial.php?tutorialid=619
Good Luck
Carrzkiss
0
MishaProgrammerCommented:
There is no activity from author.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
SQL

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.