Solved

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

Posted on 2011-09-29
7
211 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

914 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now