Java Services How to refer to database aliases

I need to write a Java Service that uses JDBC and needs to refer to the Data Sources (Alias) defined in webMethods. The Java Service is run standalone - hence has no inputs from any other services.

Please let me know how to take care of this.

thanks in advance.
KrishnaN

Here is the java code for database connectivity. To reference webMethods session data, soon.
Thanks

import java.sql.*;

public class MetaTest {

// String defining database connection

static final String dbURI = “jdbc:odbc:TransactionDB”;

public static void main(String args)
throws ClassNotFoundException, SQLException {

 // Connection reference 
 Connection conn = null; 

 try { 

   // Load database driver 
   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); 

   // Make connection 
   conn = DriverManager.getConnection(dbURI); 

   // Get the database meta data 
   DatabaseMetaData dmd = conn.getMetaData(); 

   // Display information about the database  
   // product and driver 

   if (dmd == null) { 

     System.out.println("Database meta data not available"); 

   } else { 

     System.out.println( 
       "Database Product Name   : " + 
       dmd.getDatabaseProductName()); 
     System.out.println( 
       "Database Product Version: " + 
       dmd.getDatabaseProductVersion()); 
     System.out.println( 
       "Database Driver Name    : " + 
       dmd.getDriverName()); 
     System.out.println( 
       "Database Driver Version : " + 
       dmd.getDriverVersion()); 
   } 

 } finally { 

   // Close connection 

   if (conn != null) { 
     try { 
       conn.close(); 
     } catch (SQLException sqlEx) { 
       // ignore 
     } 
   } 
 } 

}
}

KrishnaN,

I am assuiming that you want to reference the aliases defined rather than hardcoding the URL, user, password and driver settings in your code. If that is the case then you can just use the service

wm.server.db:dataSourceGet

with the database alias as the input and it will return an IData object with the URL, user, password and driver setting in the alias. From there on you can just use simple JDBC code to open a connection.

Let me know if you need more details.