Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7880695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:12:18+00:00 2026-06-03T04:12:18+00:00

I’m working through this MyBatis tutorial , and am down to an issue with

  • 0

I’m working through this MyBatis tutorial, and am down to an issue with setting up the dataSource within the SqlMapConfig.xml. The tutorial is using MySql, like every other tutorial existing on the internet it seems, but I’m using SqlServer 2008.

Please help me convert the below code to connect to a local SqlServer, or help me understand how to setup environments/how the SqlMapConfig works with the connection factory.

Links to info/tutorials would be great too.

Thanks!

<?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>

    <typeAliases>
        <typeAlias alias="Contact" type="com.name.model.Contact"/>
    </typeAliases>

    <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://localhost:3306/blog"/>
                <property name="username" value="root"/>
                <property name="password" value="root"/>
            </dataSource>
       </environment>
    </environments>

    <mappers>
       <mapper resource="com/name/data/Contact.xml"/>
    </mappers>

</configuration>

UPDATED:

<?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>

    <typeAliases>
        <typeAlias alias="Contact" type="com.name.model.Contact"/>
    </typeAliases>

    <environments default="development">
        <environment id="development">
          <transactionManager type="JDBC"/>
            <dataSource type="POOLED">
                <property name="driver" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/>
            <property name="url" value="jdbc:sqlserver://localhost(or name of server):1433;databaseName=yourdbname; catalogName=sameasdbname"/>
            <property name="username" value="root"/>
            <property name="password" value="root"/>
            </dataSource>
       </environment>
    </environments>

    <mappers>
       <mapper resource="com/name/data/Contact.xml"/>
    </mappers>

</configuration>

NOTE:
I was using the latest JDBC driver 4 with SQL 2008, and had version issues, specifically the error: “Exception data: java.lang.UnsupportedClassVersionError (com/microsoft/sqlserver/jdbc/SQLServerDriver) bad major version at offset=6 ………”

Switch to the compatible driver sqljdbc.jar over sqljdbc3/sqljdbc4.jar to fix this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T04:12:19+00:00Added an answer on June 3, 2026 at 4:12 am

    To connect to SQL Server (or any other database out there) you need two basic things:

    • an appropriate JDBC driver.
    • appropriate properties when configuring the data saource;

    For the driver I guess you can go for “the official” Microsoft JDBC Driver for SQL Server distribution which you must make available on your application’s classpath, then configure the data source properties in MyBatis configuration which involves specifying the driver class (com.microsoft.sqlserver.jdbc.SQLServerDriver if I’m not mistaken) and the connection url (which must start with jdbc:sqlserver:// instead of jdbc:mysql://).

    You can find more information on the official page which will provide appropriate links to help you through it all (just make sure you read the documentation for your version of SQL Server; SQL Server 2012 is out so Microsoft updated their docs).

    Then depending on what types of queries you are running (for a basic tutorial as that one shouldn’t be a problem) you must make sure that you use the proper SQL syntax.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.