GEOFFREY THOMPSON | Instead of creating a connection with a URL based on DB, host, port, user, password and loading the driver class and building a connection from the DriverManager, like Hemal mentioned in his post
String conURL = "........"; // connection string based on your db, ip, username and password
// Load the Driver class. Class.forName("...."); // If you are using any other database then load the right driver here.
//Create the connection using the static getConnection method Connection con = DriverManager.getConnection (conURL);
define all the things needed through the normal JNDI configuration, just as you do to use the Cisco VXML Database Element.
This will allow you to use connection pooling and all the other good things that come from the JNDI libraries.
Now in your code:
// // Create the initial context. No JNDI properties // are to be supplied here // Context initialContext = new InitialContext();
// // Create a null datasource object // DataSource dataSource = null;
// // Look up and set the datasource using the logical name // specified in the ResourceLink global tag in Tomcat\conf\context.xml // <ResourceLink global="jdbc/userDBConnection" // name="jdbc/userDBConnection" type="javax.sql.DataSource"/> // // Note that we give the full context to lookup java:comp/env/ // // You must always cast or narrow the object that JNDI // returns to the DataSource, because the JNDI lookup() // method returns a Java object. // dataSource = (DataSource) initialContext.lookup("java:comp/env/jdbc/userDBConnection");
// // Establish the connection on the data source // Connection = dataSource.getConnection();
Regards, Geoff |
| Please sign in to flag this as inappropriate. |