I got a generatorConfig.xml
like this:
<generatorConfiguration>
<classPathEntry location="D:\Workspace\springlt\src\main\resources\ojdbc6.jar" />
<context id="MyBatis3" targetRuntime="MyBatis3">
<commentGenerator>
<property name="suppressAllComments" value="true" />
</commentGenerator>
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="myurl" userId="username"
password="password">
</jdbcConnection>
<javaModelGenerator targetPackage="vn.laptrinh.domain"
targetProject="../java" />
<sqlMapGenerator targetPackage="vn.laptrinh.dao.xml"
targetProject="../java" />
<javaClientGenerator type="XMLMAPPER"
targetPackage="vn.laptrinh.dao" targetProject="../java" />
<!-- <table tableName="users" domainObjectName="User"
enableSelectByExample="false" enableDeleteByExample="false"
enableCountByExample="false" enableUpdateByExample="false">
<columnOverride column="id" javaType="Long" />
</table> -->
<table tableName="CARDUSER_MASTER" domainObjectName="CardUserMaster"
schema="CACISISS" enableSelectByExample="false"
enableDeleteByExample="false" enableCountByExample="false"
enableUpdateByExample="false">
</table>
</context>
</generatorConfiguration>
Previously, I use mysql database and I put mysql-connector-java-5.1.15-bin.jar
and mybatis-generator-core-1.3.1.jar
in ..\springlt\src\main\resources folder, then use command line to run java -jar mybatis-generator-core-1.3.1.jar -configfile generatorConfig.xml -overwrite -tables users
, project will generate domain, xml, xmlmapper
However when I change mysql-connector-java-5.1.15-bin.jar
to ojdbc6.jar
(I'm using oracle 11g), then I run and got bunches of errors:
D:\Workspace\springlt\src\main\resources>java -jar mybatis-generator-core-1.3.1.
jar -configfile generatorConfig.xml
Exception in thread "main" java.lang.RuntimeException: Exception getting JDBC Dr
iver
at org.mybatis.generator.internal.db.ConnectionFactory.getDriver(Connect
ionFactory.java:85)
at org.mybatis.generator.internal.db.ConnectionFactory.getConnection(Con
nectionFactory.java:54)
at org.mybatis.generator.config.Context.getConnection(Context.java:498)
at org.mybatis.generator.config.Context.introspectTables(Context.java:40
8)
at org.mybatis.generator.api.MyBatisGenerator.generate(MyBatisGenerator.
java:221)
at org.mybatis.generator.api.ShellRunner.main(ShellRunner.java:117)
Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.mybatis.generator.internal.ObjectFactory.externalClassForName(Obj
ectFactory.java:90)
at org.mybatis.generator.internal.db.ConnectionFactory.getDriver(Connect
ionFactory.java:82)
... 5 more
I dont' know what is the problem is. I connect to database located on server.
Any solutions would be appreciated. Thanks.
Firstly, please change this:
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="myurl" userId="username"
password="password">
</jdbcConnection>
to
<jdbcConnection driverClass="oracle.jdbc.driver.OracleDriver"
connectionURL="myurl" userId="username"
password="password">
</jdbcConnection>
and see if it is working for you