cancel
Showing results for 
Search instead for 
Did you mean: 

About JDBC System...

Former Member
0 Kudos

Hi All,

I am trying to develop a Portal Application in NWDS with java.

My requirement is to create some tables and then to access them.

I created these tables with the Dictionary Prespective in the NWDS.

To have acces to a RDBMS i read that i have to create a JDBC System and then write a code like this

IConnectorGatewayService cgService =(IConnectorGatewayService) PortalRuntime.getRuntimeResources().getService(IConnectorService.KEY);

if (cgService == null) {

throw new ConnectorException("Error in get Connector Gateway Service");

}

ConnectionProperties cp =new ConnectionProperties(request.getLocale(),request.getUser());

IConnection conn = cgService.getConnection("tempdbalias", cp);

conn = getJDBCConnection("testdbalias", request);

INativeQuery query = conn.newNativeQuery();

ResultSet result = (ResultSet)query.execute("select vendorname from vendor");

My questions are :

Do i have access in the tables created in the NWDS with the above code?

Or i have to create tables in the DB with other way?

Please i will appreciate any help.

Regards,

Ari

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

The tables created through the dictionary perspective are created in the default DB of your server. You can access that by creating any alias of the DB( through visual admin) and access the same through the following code:

InitialContext initialContext = new InitialContext();

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

connection = dataSource.getConnection();

Here SAPDB is the alias for the datasource.

Hope it helps.