Solved

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

Posted on 2011-09-29
7
216 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
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how to debug htl and js pages 8 53
dao vs facade design patterns 2 30
IntelliJ and Eclipse Neon 2 installations 4 33
Getting Variable not defined error in Python 1 38
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

713 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