Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Error querying database when attempting to run MyBatis.
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Ryan Conklin  
View profile  
 More options Nov 15 2012, 6:52 pm
From: Ryan Conklin <ryancarolin...@gmail.com>
Date: Thu, 15 Nov 2012 15:52:02 -0800 (PST)
Local: Thurs, Nov 15 2012 6:52 pm
Subject: Error querying database when attempting to run MyBatis.

The error I get is below, farther down I have included my code and my
"MapperConfig.xml". I get this error when I attempt to debug, I have
confirmed my "com.mysql.jdbc.Driver" is correct on the .xml config sheet.

org.apache.ibatis.exceptions.PersistenceException:
### Error querying database.  Cause: java.sql.SQLException: Error setting
driver on UnpooledDataSource. Cause: java.lang.ClassNotFoundException:
Cannot find class: com.mysql.jdbc.Driver
### The error may exist in mybatis/res/AddressesMapper.xml
### The error may involve
org.mybatis.generator.AddressesMapper.selectByPrimaryKey
### The error occurred while executing a query
### Cause: java.sql.SQLException: Error setting driver on
UnpooledDataSource. Cause: java.lang.ClassNotFoundException: Cannot find
class: com.mysql.jdbc.Driver

*<?xml version="1.0" encoding="UTF-8" ?>*
*<!DOCTYPE configuration*
*PUBLIC "-//mybatis.org//DTD Config 3.0//EN"*
*"http://mybatis.org/dtd/mybatis-3-config.dtd">*
*<configuration>*
*<environments default="development">*
*<environment id="development">*
*<transactionManager type="JDBC"/>*
*<dataSource type="POOLED">*
*<property name="driver" value="com.mysql.jdbc.Driver"/>*
*<property name="url" value="jdbc:mysql://10.10.12.35:3306/"/>*
*<property name="username" value="********"/>*
*<property name="password" value="*********"/>*
*</dataSource>*
*</environment>*
*</environments>*
*<mappers>*
*<mapper resource="mybatis/res/AddressesMapper.xml"/>*
*</mappers>*
*</configuration>*
*
*
*
*
*
*
*
*
*------------------------------------------------------------------*
*
*
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mybatis;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import java.io.InputStream;
import org.apache.ibatis.session.SqlSession;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.BasicConfigurator;
import org.mybatis.generator.Addresses;
import org.mybatis.generator.AddressesMapper;

/**
 *
 * @author Ryan
 */
public class MyBatis {

     //log4j setup
    static Logger logger = Logger.getLogger("MyBatis.class");

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

            BasicConfigurator.configure();
            logger.info("MyBatis Running");

        try {
              String mapconfig = "mybatis/res/MapperConfig.xml";

              InputStream inputStream =
Resources.getResourceAsStream(mapconfig);
              SqlSessionFactory sqlSession = new
SqlSessionFactoryBuilder().build(inputStream);

              SqlSession session = sqlSession.openSession();
        try {
              AddressesMapper mapper =
session.getMapper(AddressesMapper.class);
              Addresses addresses = mapper.selectByPrimaryKey(101);
            } finally {
              session.close();
            }

    }

     catch( Exception ex) {
            ex.printStackTrace();
        }
    }


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »