cancel
Showing results for 
Search instead for 
Did you mean: 

how to access a table contents using datasource

Former Member
0 Kudos

hi to all Gurus,

I could not able to aceess table contents through a datasource.

How could i assign a datasource to some database.

i have to use oracle database. Here is my code.

InitialContext context = new InitialContext();

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

con=ds.getConnection();

//Upto here everything works fine now,

rs1=con.createStatement().executeQuery("");

i have to create table using this datasource

Please tell me how i will assign tables to this datasource.

Please help me.

Thanks and Regards;

Pankaj Kumar

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hello Pankaj,

r u able to get all the records of the table into some node ?

if yes, then in the wdDomodifyview of the view, you can dynamically bind this node to the datasource property of the table

Hope this helps

Thanks and Regards

Kapil

Former Member
0 Kudos

Hi kapil,

Thanx 4 quick reply. My question is how could i know that which table i can access through the datasource. and how could i make a table to be accessed by a datasource.

Suppose i have a table named as "Employee" in oracle server with database name as MYDATABASE. Now how can i access the table contents through the datasource created in "VISUAL ADMINISTRATOR" of SAP J2EE Server.

Please Help me.

Thanks,

Pankaj kumar.

Former Member
0 Kudos

Hi Pankaj,

This is the code for accessing the database using datasource

InitialContext initialContext= new InitialContext ();

DataSource dataSource = (DataSource)initialContext.lookup("Datasource");

java.sql.Connection conn = dataSource.getConnection();

Then you can write SQL query to obtain the values from table

Hope this helps

Kind Regards,

Saravanan K

Former Member
0 Kudos

Hi Pankaj,

sorry I missed one, this is the correct version,

InitialContext initialContext= new InitialContext ();

DataSource dataSource = (DataSource)initialContext.lookup(jdbc/"Alias name");

java.sql.Connection conn = dataSource.getConnection();

ps: alias name that was created by you

Then you can write SQL query to obtain the values from table

Hope this helps

Kind Regards,

Saravanan K

Former Member
0 Kudos

Hi sarvanan,

What you told its ok. 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.