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

JSP: JNDI to SQL Server 2008

Hi everyone,

I'm doing a website in JSP. I'm using Tomcat 6 and have gotten the site talking to the backend file. However, when I go to add in a database connection, I have problems. This is my first time trying to connect to a SQL Server 2008 database. In the past I have used Oracle.

So I have the Context.xml file in the META-INF folder. This is an example of the file I had before with the Oracle information:

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <Context
  3.     override="true"
  4.     reloadable="true">
  5.   <Resource
  6.     auth="Container"
  7.     name="jdbc/myDatabase"
  8.     type="javax.sql.DataSource"
  9.     driverClassName="oracle.jdbc.OracleDriver"
  10.     username="lita"    
  11.     password="123"
  12.     maxIdle="1"
  13.     maxWait="5000"
  14.     maxActive="3"
  15.     removeAbandoned="true"
  16.     url="jdbc:oracle:thin:@localhost:1521:XE"
  17.     removeAbandonedTimeout="0"
  18.     factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"/>
  19. </Context>


For SQL Server 2008:
I know the driverClassName will be "com.microsoft.sqlserver.jdbc.SQLServerDriver"

and that the url will be something like "jdbc:sqlserver://localhost;DatabaseName=Pie"

But I'm not sure exactly what this file will look like. I need help getting the right information set.



So:
- Database name: Pie
- Typical connection string I would use in C#: connectionString="Provider=SQLOLEDB;Data Source=XP_LAPTOP\SQLEXPRESS;Integrated Security=SSPI;Initial Catalog=Pie"
- I just use Windows Authentication to access SQL Server 2008 so would I set username and password to be my Windows login or just leave as blank?



Also: name="jdbc/myDatabase" - can this be any name so long as it matches up in the code?

Expand|Select|Wrap|Line Numbers
  1. private Connection con;
  2.  
  3. Context init = new InitialContext();
  4. Context ctx = (Context) init.lookup("java:comp/env");
  5. DataSource ds = (DataSource) ctx.lookup("jdbc/myDatabase");
  6. con = ds.getConnection();



Any help would be greatly appreciated! Thanks :)
May 7 '10 #1
0 2732

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

Similar topics

3
by: =?Utf-8?B?T2xpdmllciBNQVRST1Q=?= | last post by:
I'm trying to run an ASP.NET 2.0 web site on Windows Server 2008 RC1. I encounter a server error : HTTP 500.19 - Configuration data is invalid IIS7 claims that the <appSettingssection in web.config...
1
by: =?Utf-8?B?S2luZXRpYyBKdW1wIEFwcGxpZmUgZm9yIC5ORVQg | last post by:
Do want to attend the Microsoft SQL Server 2008 and Visual Studio 2008 sessions at your home PC?. Yes now it is possible. Microsoft has scheduled a Webcasts for you on SQL Server 2008 and Visual...
1
by: =?Utf-8?B?bWFzYWtpeQ==?= | last post by:
Hello, I'm trying to develop 32-bit Windows Native C/C++ application using Visual Studio 2008, on 64-bit Windows Server 2008. Q1. Is it possible to develop 32-bit C/C++ application using VS 2008...
1
by: Ken Fine | last post by:
I have set up Microsoft Search Server 2008 Express. I want to know how I can query against it and return results in a form that can be bound to ASP.NET controls like ListViews. If there's simply...
1
by: Chris O'C | last post by:
See: http://blogs.zdnet.com/microsoft/?p=1519 "Microsoft officials announced at TechEd South Africa on August 6 that SQL Server 2008 has been released to manufacturing. "Microsoft officials...
1
by: =?Utf-8?B?QW50amU=?= | last post by:
I need product keys for Terminal Server Windows Server 2008 access (CALs) under MSDN - TSLM Service said they cannot provide product keys for the access.
6
by: AAaron123 | last post by:
I need to move a database from sql server 2008 to sql express 2008. Will backing up the sql server 2008 database to a file and then using that file to restore to sql express 2008 work? I don't...
2
by: =?Utf-8?B?SmVycnkgQw==?= | last post by:
I have a server 2008 IIS 7.0 with indexing service installed. I have created the catalog and have a test page using these posts:...
1
by: BobLewiston | last post by:
I installed SQL Server 2008 Express, basic edition (SQLEXPR32_x86_ENU_Bootstrapper.exe, version 9.0.30729.1) without any problem. Then I attempted to install AdventureWorks Sample Databases for...
0
by: IT Couple | last post by:
Hi 1) Question one I'm installing SQL Server 2008 Enterprise Edition on Windowds XP (remotely) and in the 'readme' file it tells me to install SP1 first and then SQL Server 2008 but when I try to...
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.