Solved

java - need code piece to connect to ms sql server 2005

Posted on 2011-09-29
7
218 Views
Last Modified: 2013-11-13
are there any codpieces/mehtods that will let me connect to ms sql server 2005 and a query statement tp:

1) select data from table and populate a session varaible
2) update a table with a session varaible
0
Comment
Question by:GlobaLevel
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
7 Comments
 
LVL 47

Accepted Solution

by:
for_yan earned 500 total points
ID: 36816219
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36816235
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36816246

this is where you download the driver
http://www.microsoft.com/download/en/details.aspx?id=21599
0
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
LVL 47

Expert Comment

by:for_yan
ID: 36816259
0
 
LVL 10

Author Comment

by:GlobaLevel
ID: 36816288
So I am runnIng my JSP's thru apache on windows OS with ms SQL server 2005 back end, is that a problem? All one server
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36816306
No I don't think it is a problem -  I guess you are also runnning Tomcat that drives your JSP - you need to make sure that you have the driver jar avialable
in the classpath - I guess it should be wirthin WEB-INF/lib fiolder

0
 
LVL 47

Expert Comment

by:for_yan
ID: 36816334
Well, after you select data form table with JDBC, you can
set attributes of your session something like that:


HttpSession session = request.getSession(true);


ResultSet rs = statement.executeQuery("select filed1, flied2, field3 from table_name");
while(rs.next()){
String s0 = rs.getString(1);
String s1 = rs.getString(2);
String s2 = rs.getString(3);

session.setAttribute("name1", s0);
session.setAttribute("name2", s1);
session.setAttribute("name3", s2);


}
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Make the most of your online learning experience.
Six Sigma Control Plans
Starting up a Project

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question