cancel
Showing results for 
Search instead for 
Did you mean: 

Oracle Server Connection: Error finding JNDI Name

Former Member
0 Kudos

I am working on moving our RDC Component over to use Crystal Reports for Eclipse.

I have latest version of Crystal Reports for Eclipse (I think) - 2.0.6.r916. We use Oracle Server connections.

I am trying to rework some sample code so that I can connect my rpt to our database. I want to update whatever oracle server connection info the report currently has with a new db/username/password.

Whenever I try to use this code I get an 'Error finding JNDI Name'.

Here is my current code:

private static void switch_tables(DatabaseController databaseController) throws ReportSDKException

{

//For now just hardcode values until I can figure out how to conn

final String DBUSERNAME = "myusername";

final String DBPASSWORD = "mypassword";

final String DATABASE_NAME = "mydb.world";

//Obtain collection of tables from this database controller.

Tables tables = databaseController.getDatabase().getTables();

//Set the datasource for all main report tables.

for (int i = 0; i < tables.size(); i++) {

ITable table = tables.getTable(i);

//Change connection information properties.

IConnectionInfo connectionInfo = table.getConnectionInfo();

PropertyBag connInfoProperties = new PropertyBag();

connInfoProperties.putBooleanValue("Trusted_Connection", false);

connInfoProperties.put("PreQEServerName", DATABASE_NAME);

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

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

connInfoProperties.put("ServerName", DATABASE_NAME);

connInfoProperties.put("Server", DATABASE_NAME);

connectionInfo.setAttributes(connInfoProperties);

//Set database username and password.

if (DBUSERNAME != null) {

connectionInfo.setUserName(DBUSERNAME);

connectionInfo.setPassword(DBPASSWORD);

}

connectionInfo.setKind(ConnectionInfoKind.SQL);

table.setConnectionInfo(connectionInfo);

//Update old table in the report with the new table.

//ERROR comes from this line: 'Error finding JNDI name (mydb.world)'

databaseController.setTableLocation(table, tables.getTable(i));

}

}/switch_tables/

Can anyone point me in the right direction? Thanks!

Edited by: kisetta on Sep 29, 2010 8:38 PM

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hello,

Oracle doesn't use the concept of a database name. Set it to the empty string value and test again.

Thank you

Don

Former Member
0 Kudos

Which of the properties should be set to an empty string? I know I must have to set the database I'm connecting to somewhere.

0 Kudos

As I said, the database name doesn't get set.

The Server name is either the Oracle Instance or the DSN name or actual server name depending on how you have it set up.

Thank you

Don

Former Member
0 Kudos

Ok let me back up. When I go to run the report in Crystal against an Oracle Server connection - I get a popup that gives me 3 fields - Service, User ID, and Password.

Where does Service go? What property do I set to connect to my oracle database? Server? Servername?

Because I'm setting all 3 here (PreQEServerName, Server, ServerName) to the service and its giving me the 'Error finding JNDI Name'. Am I missing a property - should I be referring to a 'Service' property?

private static void switch_tables(DatabaseController databaseController) throws ReportSDKException

{

final String SERVICE = "mydb.world";

final String USERID = "myusername";

final String PASSWORD = "mypassword";

//Obtain collection of tables from this database controller.

Tables tables = databaseController.getDatabase().getTables();

//Set the datasource for all main report tables.

for (int i = 0; i < tables.size(); i++) {

ITable table = tables.getTable(i);

//Change connection information properties.

IConnectionInfo connectionInfo = table.getConnectionInfo();

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", SERVICE);

connInfoProperties.put("Server", SERVICE);

connectionInfo.setAttributes(connInfoProperties);

//Set database username and password.

if (USERID != null) {

connectionInfo.setUserName(USERID);

connectionInfo.setPassword(PASSWORD);

}

connectionInfo.setKind(ConnectionInfoKind.SQL);

table.setConnectionInfo(connectionInfo);

//Update old table in the report with the new table.

//ERROR comes from this line: 'Error finding JNDI name (mydb.world)'

databaseController.setTableLocation(table, tables.getTable(i));

}

}/switch_tables/

Edited by: kisetta on Oct 6, 2010 8:01 PM

0 Kudos

Hello,

final String SERVICE = "mydb.world";

Is mydb.world the actual name of your Oracle Instance or physical Server name?

Don't refer to the native Oracle Driver, it's not using it, comment the line out:

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

I think it may be easier if you get this to work in the CR Designer first and then use your code to view the various properties in debug mode. Then you'll see what needs to be set.

Thank you

Don

Former Member
0 Kudos

'mydb.world' is the name of my Oracle Instance - its what I use in the tns names file to refer to that database instance.

As in:

mydb.world = (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST='HOST')(PORT=1521))(CONNECT_DATA=(SID='SID')))

What do you mean get it to work in CR Designer? I can get it to work by running a report directly in Crystal Reports 2008 - I can run the report thorough that and connect to the database. It works fine by setting the server/userid/password.

I have Crystal Reports for Eclipse and that's what I'm trying to use to get this working.

Is there some other tool called CR Designer that I need to have installed? How on earth do I turn on debug mode?

This kind of thing seems like it really should have an example somewhere - I can't be the only one trying to connect up with a basic Oracle connection.

Former Member
0 Kudos

Also if I comment out this line:

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

I get a different error message - 'Database driver name is not supported: null'.

Do I need to set a database driver property?

ted_ueda
Employee
Employee
0 Kudos

Crystal Reports for Eclipse product and its associated reporting SDK - the Crystal Report Java SDK - only supports Java-based data sources.

Since native Oracle isn't a Java-based driver, what the CR Java engine does is try and connect to a JNDI data source with the same name as the data source name.

So what you need to do is modify your report from using Oracle native to Oracle JDBC thin-client driver. It's easiest to do this in the Crystal Reports Designer rather than programmatically.

Sincerely,

Ted Ueda

Former Member
0 Kudos

Ted,

Is it possible to keep the crystal rpt with the Oracle native connection and change the connection to Oracle JDBC thin-client driver programmatically?

See we are upgrading from using the RDC component so I'd rather not have to change all of our existing rpts to use a different kind of Oracle connection if I can help it. Especially if there is a way to do this in the code.

Thanks for the help!

ted_ueda
Employee
Employee
0 Kudos

You can do that - and you really only have to do it once and then save the rpt file.

That would eliminate the overhead of changing the schema - there is overhead, since the CR engine will have to validate the changes.

How that's typically done is to create a report against the connection you want, then read off all the connection properties programmatically.

Then in code, take the target document and set new connection properties to the ones you want.

Sincerely,

Ted Ueda

Answers (1)

Answers (1)

Former Member
0 Kudos

If you want to reference a JNDI datasource, we found the magic property was "JND Datasource Name" so our IConnectionInfo is set up like this:


    private IConnectionInfo getJNDIConnectionInfo() {
        IConnectionInfo connectionInfo = new ConnectionInfo();
        PropertyBag propertyBag = new PropertyBag();

        propertyBag.put("JNDI Datasource Name", getDataSourceURL());

        // required!!! (However, don't look for it in libraries. It is just a tag))     
        propertyBag.put("Database DLL", "crdb_jdbc.dll");
        
        connectionInfo.setAttributes(propertyBag);
        
        connectionInfo.setKind(ConnectionInfoKind.SQL);

        return connectionInfo ;
    }

Where getDataSourcURL() returns the datasource e.g., "java:comp/env/jdbc/bpsprojectreport"

I should qualify this by saying that in weblogic/oracle land, we have serious problems swapping datasources programmatically. But it seems to work fine for us in other environments such as tomcat or WebSphere.