Unixodbc-the driver error cannot be found when Log4cxx logs are output to MySQL.

Source: Internet
Author: User
Tags driver manager odbc connection
Hi, guys! Using the log4cxx log framework to output log content to the database (MySQL) has not been successful, and I do not know what steps are wrong. I hope everyone can help us or recommend a better log system. thank you. ^_^ --- ** Runtime environment **: Ubuntu12.0432bit + EclipseCDT ** log4cxx **: the apache-log4cxx-0.10.0log4cxx supports two ODBC options (iODBCunixODBC), which are managed in unixODBC form by adding options. co... unixodbcmysqllog4cxx

Hi, guys!
Using the log4cxx log framework to output log content to the database (MySQL) has not been successful, and I do not know what steps are wrong. I hope everyone can help us or recommend a better log system. thank you. Pai_^

Running environment: Ubuntu 12.04 32bit + Eclipse CDT
Log4cxx: Apache-log4cxx-0.10.0
Log4cxx supports two ODBC options (iODBC/unixODBC). here, the unixODBC mode is used for management.
By adding the option./configure -- with-ODBC = unixODBC, the compilation passes.
Then configure the driver and data source of unixODBC.Isql log4cxxConnection established
However, the following error is always reported when Log4cxx is used in the code for output.

log4cxx: Failed to connect to database. - [unixODBC][Driver Manager]Data source name not found, and no default driver specified

Suspect 1:

Whether environment variables are not added to Ecplise;
Check ODBC data and add the ODBCSYSINI, ODBCINSTINI, and ODBCINI variables to Eclipse.

Suspect 2:

The log4cxx configuration is incorrect. Is there any official method!

Configuration content:
/Etc/odbcinst. ini

[MySQL]Description = MySQLDriver = /usr/lib/i386-linux-gnu/odbc/libmyodbc.soSetup = /usr/lib/i386-linux-gnu/odbc/libodbcmyS.soFileUsage = 1  

/Etc/odbc. ini

[log4cxx]Description = The Database for Logging SystemTrace = onTraceFile = stderrDriver = MySQLSERVER = localhostPORT = 3306DATABASE = logUSER = root PASSWORD = 56789

Log4cxx. xml

    
       
      
   
     
        
   
Progress: _Time: 20150702_

View the Log4cxx source code and record logs in the database mode. the ODBCAppender is used.src/main/cpp/odbcappender.cppThe author's original code usesSQLxxxW ()Perform DriverConnect and SQLExecDirect operations.WIt adopts Unicode encoding. In short, I keep stuck here and keep reporting that the data source cannot be found. As a resultSQLxxxW()ModifySQLxxx()MethodSQLWCHARChange to correspondingSQLCHARThat is, a non-width byte operation is used to successfully locate the data source and call the data source.
However, this causes Chinese problems.

Doubt
The Driver configured in odbcinst. ini is indeed libmydbc5w. so, that is, the Driver uses Unicode! (* Corresponds to libmydbc5a. so *). so far, I still don't know where I am going wrong. it is impossible for the author to use SQLxxxW () for ODBC Connection without any justification.

I added
# Define SQL _WCHART_CONVERT

#if !defined(LOG4CXX)#define LOG4CXX 1#endif#include 
   
    #if LOG4CXX_HAVE_ODBC#if defined(WIN32) || defined(_WIN32)#include 
    
     #endif#define SQL_WCHART_CONVERT#include 
     
      #endif
     
    
   

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.