cancel
Showing results for 
Search instead for 
Did you mean: 

problem in getting data from table using datasource

Former Member
0 Kudos

i am able to get the datasource and connection also. but my problem is how to assign a table to the data source.

How could i know which are the tables we can access through the datasource.

My code is----


InitialContext context = new InitialContext();

DataSource ds = (DataSource)context.lookup("jdbc/Tit_Ora");

con=ds.getConnection();

What are the things i have to do so that a table created in a database could be accessed via this datasource.

How to bind the table with the datasource.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Pankaj,

Datasource is a alias name that refers to a database and is configured in Visual Admin.In your case "Tit_Ora" is the datasource which points to your database.Using the connection,con you can access any of the table in database.

I will provide code snippet to demonstrate

Statement st=con.createStatement();//con is the connection created by you

ResultSet rs=st.executeQuery("Query to a table u wish");

then you can use any loop to access the resultset..

Hope this will helps

Kind regards,

Saravanan K

Former Member
0 Kudos

Hi Saravanan,

My problem is what configuration i need to do in visual administrator so that a datasource refers to a database.

Please help me out.

Thanks;

Pankaj Kumar

Former Member
0 Kudos

HI Pankaj,

AFTER GETTING A CONNECTION U HAVE TO CREATE statement

using Statement stmt = connection.createment();

afterthat we need to call executequery method

ResultSet rs =stmt.executeQuery(jdbcQuery);

Resultset is collection of records

u can loop thru it and get that using getString("columnName);

hope this will solvs ur problem

With Regads

Naidu