title: SqlServer/MyBatis SqlMapConfig datasource setup
body: <p>I'm working through <a href="http://loianegroner.com/2011/02/getting-started-with-ibatis-mybatis-xml-configuration/" rel="nofollow">this MyBatis tutorial</a>, 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.</p>
  
  <p>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.</p>
  
  <p>Links to info/tutorials would be great too.</p>
  
  <p>Thanks!</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE configuration
      PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
      "http://mybatis.org/dtd/mybatis-3-config.dtd"&gt;
  
  &lt;configuration&gt;
  
      &lt;typeAliases&gt;
          &lt;typeAlias alias="Contact" type="com.name.model.Contact"/&gt;
      &lt;/typeAliases&gt;
  
      &lt;environments default="development"&gt;
          &lt;environment id="development"&gt;
            &lt;transactionManager type="JDBC"/&gt;
              &lt;dataSource type="POOLED"&gt;
                  &lt;property name="driver" value="com.mysql.jdbc.Driver"/&gt;
                  &lt;property name="url" value="jdbc:mysql://localhost:3306/blog"/&gt;
                  &lt;property name="username" value="root"/&gt;
                  &lt;property name="password" value="root"/&gt;
              &lt;/dataSource&gt;
         &lt;/environment&gt;
      &lt;/environments&gt;
  
      &lt;mappers&gt;
         &lt;mapper resource="com/name/data/Contact.xml"/&gt;
      &lt;/mappers&gt;
  
  &lt;/configuration&gt;
  </code></pre>
  
  <p><strong>UPDATED:</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE configuration
      PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
      "http://mybatis.org/dtd/mybatis-3-config.dtd"&gt;
  
  &lt;configuration&gt;
  
      &lt;typeAliases&gt;
          &lt;typeAlias alias="Contact" type="com.name.model.Contact"/&gt;
      &lt;/typeAliases&gt;
  
      &lt;environments default="development"&gt;
          &lt;environment id="development"&gt;
            &lt;transactionManager type="JDBC"/&gt;
              &lt;dataSource type="POOLED"&gt;
                  &lt;property name="driver" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/&gt;
              &lt;property name="url" value="jdbc:sqlserver://localhost(or name of server):1433;databaseName=yourdbname; catalogName=sameasdbname"/&gt;
              &lt;property name="username" value="root"/&gt;
              &lt;property name="password" value="root"/&gt;
              &lt;/dataSource&gt;
         &lt;/environment&gt;
      &lt;/environments&gt;
  
      &lt;mappers&gt;
         &lt;mapper resource="com/name/data/Contact.xml"/&gt;
      &lt;/mappers&gt;
  
  &lt;/configuration&gt;
  </code></pre>
  
  <p><strong>NOTE:</strong>
  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 ........."</p>
  
  <p>Switch to the compatible driver sqljdbc.jar over sqljdbc3/sqljdbc4.jar to fix this.</p>