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

Datasource

30
We currently have an application running on JBoss Server 4.0. I am designing a JSP page that needs to access the database to retrieve some results. This page is inside a seperate .WAR file. My question is that, is there a way to connect directly to the database used by JBoss e.g. using Datasource. What is datasource and how can it be used to connect from a different modules within the same application e.g. other JAVA classes. I am kind of new to enterprise applications and need some help on this. I want to avoid using Connection code below and use Datasource which is already active somehow:

Expand|Select|Wrap|Line Numbers
  1.       Connection conn = DriverManager.getConnection
  2.       ("jdbc:microsoft:sqlserver://server:1433","user","password"); 
  3.       Statement stmt = conn.createStatement();
  4.       ResultSet rset= stmt.executeQuery("select * from table");
  5.       while(rset.next()){ string = rset.getString(1);} 
  6.       conn.close();
  7.       stmt.close();
  8.       rset.close();
  9.       }catch (SQLException ex){}

Any help will be great.
Dec 2 '08 #1
2 1800
Dököll
2,364 Expert 2GB
Thanks for posting part of your code good buddy...

I suspect you ar using a bean, is that it?

I'll fetch your notes later and see what can be salvaged.

In a bit!
Dec 3 '08 #2
JosAH
11,448 Expert 8TB
@Dököll
No, the OP wants to use a DataSource defined by the vendor (JBoss). A DataSource is an object associated with a name in a JNDI Context. JBoss supplies the Context and you can lookup the DataSource given its name. The OP doesn't want to use a DriverManager and get a Connection from it; the OP wants to get a Connection from the DataSource so there is no need to look at the supplied code. Normally these JNDI definition details can be found in some xml file.

kind regards,

Jos
Dec 3 '08 #3

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

Similar topics

13
by: DraguVaso | last post by:
Hi, I need a function that gives me the number of Columns shown in a DataGrid. So I don't need to know the number of columns shown in tha DataSource, because this number can be completely...
3
by: Alvaro E. Gonzalez V. | last post by:
Hello!!! I'm building a control that in a property assign a Dataset which they are initialized and another property Like DataMember. Similar as it happens to the DataSource property of a...
4
by: dyw55a | last post by:
Donna Mar 15, 10:11 am show options Newsgroups: microsoft.public.dotnet.framework.adonet From: "Donna" <dyw...@yahoo.com> - Find messages by this author Date: 15 Mar 2005 10:11:56 -0800...
1
by: Ed Chiu | last post by:
Hi, Is there a way to clone datasource of one datagrid to another? I tried: DataGrid2.datasource = DataGrid1.datasource DataGrid2.Databind() Does not seem to work
4
by: Stephen | last post by:
IN VB.NET I have a form with a ListBox and would like to set the DataSource property at design-time but I can't seem to declare any kind of variable that will show up in the list. I have tried a...
4
by: Jim Katz | last post by:
I have an application that updates a strongly typed data set at run time. I'd like to dynamically create a table that connects to a run time data table. For displaying the data, this works well. ...
4
by: ECathell | last post by:
I am trying to databind 2 combo boxes to the same datasource but different fields using the same lookup table. The information in combobox2 is duplicating combobox 1(ie it appears to be gathering the...
4
by: SHEBERT | last post by:
Here is an example of a SortedList that works as a datasource to the ComboBox and a generic SortedList<that does not works as a datasource to the ComboBox. Why? If I use List and generic List<>,...
2
by: shapper | last post by:
Hello, I created a Repeater at runtime with an AccessDataSource.Everything Works fine! Now I need to use the same repeater but with a DataSource created in my VB.Net code. I created a...
5
by: Ken Varn | last post by:
I have just started using VS.NET 2005 after using VS.NET 2003. One of the things that I noticed is that in ASP.NET, the DataSource property for TextBoxes and other web controls is no longer...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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...

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.