22 Feb 2013

Exception getting JDBC Driver

Problem: When generating the iMbatis mapping files in Eclipse, "Fail to generate mapper files: Exception getting JDBC Driver" error is encountered.

Figure 1: Exception getting JDBC Driver

Cause: Eclipse cannot find the JDBC library file.

Solution: Add <classPathEntry> to the "generatorConfig.xml" to define the class path of the library file.

generatorConfig.xml

<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd" > <generatorConfiguration> <classPathEntry location="/Users/adaprognotebook/lib/ojdbc6.jar"/> <context id="system" > <plugin type="org.mybatis.generator.plugins.CaseInsensitiveLikePlugin" /> <jdbcConnection driverClass="oracle.jdbc.driver.OracleDriver" connectionURL="jdbc:oracle:thin:@//127.0.0.1:1521/books" userId="ada" password="pass123" /> <javaModelGenerator targetPackage="com.blogspot.adaprognotebook.model" targetProject="books" /> <sqlMapGenerator targetPackage="com.blogspot.adaprognotebook.dao.mybatis.mapper" targetProject="books/src/conf" /> <javaClientGenerator targetPackage="com.blogspot.adaprognotebook.dao.mybatis" targetProject="books" type="XMLMAPPER" /> <table schema="books" tableName="AUTHROS" /> </context> </generatorConfiguration>

No comments: