on 07-15-2006 8:16 AM
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.