File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC 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
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Oracle JDBC java/log4j problem." Watch "Oracle JDBC java/log4j problem." New topic
Author

Oracle JDBC java/log4j problem.

Kumar Shanmugam
Greenhorn

Joined: May 14, 2004
Posts: 29
HI,
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 log4j.properties file.
log4j.appender.JDBC2=org.apache.log4j.jdbc.JDBCAppender
log4j.appender.JDBC2.driver=oracle.jdbc.driver.OracleDriver
log4j.appender.JDBC2.url=jdbcracle:thin:@Server:port:instance
log4j.appender.JDBC2.user=user
log4j.appender.JDBC2.password=password

Note: I am able to log messages using FileAppender.

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

Siva.
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3704
    
    5

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?


My Blog: Down Home Country Coding with Scott Selikoff
Kumar Shanmugam
Greenhorn

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 log4j.properties files also.
Kumar Shanmugam
Greenhorn

Joined: May 14, 2004
Posts: 29
Scott,
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=org.apache.log4j.jdbc.JDBCAppender
log4j.appender.db.Driver=oracle.jdbc.driver.OracleDriver
log4j.appender.db.URL=jdbc racle:thin:server:1523 bname
log4j.appender.db.user=username
log4j.appender.db.password=password
log4j.appender.db.sql=INSERT INTO LOG VALUES ('%d %-5p -%F %m')
log4j.appender.db.layout=org.apache.log4j.PatternLayout
log4j.appender.db.layout.ConversionPattern=%d %-5p - %m
log4j.appender.db.Threshold=debug
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Oracle JDBC java/log4j problem.