Skip to Content
0
Former Member
Dec 15, 2010 at 06:19 PM

Jdbc Connection And Crystal Reports

152 Views

Hi there;

A tipical jdbc connection , that i found in my "googles" was something like this;

PropertyBag connInfoProperties = new PropertyBag();

connInfoProperties.putBooleanValue("Trusted_Connection", false);

connInfoProperties.put("PreQEServerName", SERVICE);

connInfoProperties.put("Server Type", "Oracle Server");

connInfoProperties.put("Database DLL", "crdb_oracle.dll");

connInfoProperties.put("ServerName", "");

connInfoProperties.put("Server", SERVICE);

And so - one .....

But What I'm looking for is some thing is about passing one connection aready stabilished ; I mean , I want to prepare my connection envirorment before I pass it to crystal;

Some thing like this connection "getConnection" result function; how can i pass it into crystal report?

final class GetConnection {

/** Uses JNDI and Datasource (preferred style). */

static Connection getJNDIConnection(){

String DATASOURCE_CONTEXT = "java:comp/env/jdbc/blah";

Connection result = null;

try {

Context initialContext = new InitialContext();

if ( initialContext == null){

log("JNDI problem. Cannot get InitialContext.");

}

DataSource datasource = (DataSource)initialContext.lookup(DATASOURCE_CONTEXT);

if (datasource != null) {

result = datasource.getConnection();

}

else {

log("Failed to lookup datasource.");

}

}

catch ( NamingException ex ) {

log("Cannot get connection: " + ex);

}

catch(SQLException ex){

log("Cannot get connection: " + ex);

}

return result;

}