• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Oracle JDBC java/log4j problem.

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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=jdbc:oracle: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.
 
author
Posts: 4335
39
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Kumar Shanmugam
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
reply
    Bookmark Topic Watch Topic
  • New Topic