File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Oracle JDBC java/log4j problem. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Oracle JDBC java/log4j problem." Watch "Oracle JDBC java/log4j problem." New topic

Oracle JDBC java/log4j problem.

Kumar Shanmugam

Joined: May 14, 2004
Posts: 29
I am using log4j in my java application to log error messages using JDBCAppender to record the messages in DB tables.

I am getting this error in JDeveloper.

log4j:ERROR Failed to excute sql
java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

Here is my file.

Note: I am able to log messages using FileAppender.

Please let me know if anybody have any solutions for this problem.

Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3749

Is the database connection working without the logger? Since its a java.sql.SQLException I'm tempted to say the problem has nothing to with logging although I could be wrong. Could you post the code you are using to make the connection and/or setup the jdbc logger?

Btw, why do you have a Microsoft ODBC driver manager with an Oracle JDBC driver? Am I the only one that things thats odd?

[OCA 8 Book] [Blog]
Kumar Shanmugam

Joined: May 14, 2004
Posts: 29
Thanks for your reply.

I am using Connection Pooling through OAS for other SQL DB operations.
yes. I was also confused about this mix up of ODBC / JDBC.

I will paste the other connection code for your reference.

Context ctx = new InitialContext();
DataSource ds = (DataSource)ctx.lookup(Datasourcename);
conn = ds.getConnection();

Please let me know whether I need to call a datasource in this files also.
Kumar Shanmugam

Joined: May 14, 2004
Posts: 29
This problem got solved as the static variables used for the JDBCAppender class are case sensitive.

I modifed the variables Driver and URL. Now it is working for me.

Thanks for your reply.

Here is the corrected code:

log4j.appender.db.URL=jdbc racle:thin:server:1523 bname
log4j.appender.db.sql=INSERT INTO LOG VALUES ('%d %-5p -%F %m')
log4j.appender.db.layout.ConversionPattern=%d %-5p - %m
I agree. Here's the link:
subject: Oracle JDBC java/log4j problem.
It's not a secret anymore!