This is where you need to provide all configurations for iBatis. Create an XML file with name SqlMapConfig.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMapConfig PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN" "
http://ibatis.apache.org/dtd/sql-map-config-2.dtd">
<sqlMapConfig>
<transactionManager type="JDBC">
<dataSource type="SIMPLE">
<property name="JDBC.Driver" value="com.mysql.jdbc.Driver"/>
<property name="JDBC.ConnectionURL" value="jdbc:mysql://localhost:3306/testdb"/>
<property name="JDBC.Username" value="root"/> <property name="JDBC.Password"
value=""/>
</dataSource>
</transactionManager>
<sqlMap resource="com/Employee.xml"/> </sqlMapConfig>
Lets understand the above code :
<transactionManager type=”JDBC”>
type can be JDBC, JTA,External
JDBC Alias for com.ibatis.sqlmap.engine.transaction.jdbc.JdbcTrasactionConfig
JTA alias for com.ibatis.sqlmap.engine.transaction.jta.JtaTransactionConfig
External alias for com.ibatis.sqlmap.engine.transaction.external.ExternalTransactionConfig
<dataSource type=”SIMPLE”>
datasouce can be SIMPLE, DBCP, JNDI
SIMPLE is an alias for com.ibatis.sqlmap.engine.datasource.
SimpleDataSourceFactory DBCP is an alias for com.ibatis.sqlmap.engine.datasource.
DbcpDataSourceFactory JNDI is an alias for com.ibatis.sqlmap.engine.datasource.JndiDataSourceFactory.
While using JNDI :
Use the following code
<dataSource type=”JNDI”>
<transactionManager type="JTA">
<property name = "UserTransaction" value ="java:/emp/EmlpoyeeTransaction" />
<datasource type ="JNDI" > <property name ="DataSource" value ="java:/comp
/Employee" />
<datasource>
</transactionManager>
* <property name = "UserTransaction" is optional
DataSource properties :
<property name="JDBC.Driver" value="com.mysql.jdbc.Driver"/>
provide the driverName
<property name="JDBC.ConnectionURL" value="jdbc:mysql://localhost:3306/testdb"/>
provide the connection URL
<property name="JDBC.Username" value="root"/>
<property name="JDBC.Password" value=""/>
provide the username and password
Optional properties
<property name="JDBC.AutoCommit" value="true"/>
<property name="Pool.MaximumActiveConnections" value="10"/>
<property name="Pool.MaximumIdleConnections" value="5"/>
<property name="Pool.MaximumCheckoutTime" value="100000"/>
<property name="Pool.MaximumTimeToWait" value="400"/>
<property name="Pool.PingQuery" value="select 1 from Enployee"/>
<property name="Pool.PingEnabled" value="false"/>
<sqlMap resource="com/Employee.xml"/>
Used to add the xml where the sql queries have been written in another XML file . Should be present in the class path. Alternatively to load files from a URL <sqlMap url="file://c:/Employee/Employee.xml"/> Related Articles:
Introduction to IBatis Tutorial -Part 3
IBatis vs Hibernate ? Which one to choose?



24 comments
Introduction to IBatis Tutorial -Part 1 - Golmuri says:
August 17, 2008 at 3:59 pm (UTC 5.5)
[...] Introduction to IBatis Tutorial -Part 2 IBatis Tutorial – Sample Application Step 1 [...]
Like or Dislike:
0
0
bad credit loans says:
December 30, 2009 at 6:53 am (UTC 5.5)
Hidden due to low comment rating. Click here to see.
Poorly-rated. Like or Dislike:
0
3
banking online legal issues says:
April 2, 2010 at 8:51 am (UTC 5.5)
Hidden due to low comment rating. Click here to see.
Poorly-rated. Like or Dislike:
0
3
does betfair loophole work says:
April 9, 2010 at 3:10 am (UTC 5.5)
Just what I needed to take the edge off after a intense day. Excellent writing that really gets the point across. Thank you for sharing.
Like or Dislike:
0
2
Tyson F. Gautreaux says:
April 11, 2010 at 2:23 am (UTC 5.5)
Hidden due to low comment rating. Click here to see.
Poorly-rated. Like or Dislike:
0
3
0 Credit Cards says:
April 11, 2010 at 4:30 am (UTC 5.5)
Hidden due to low comment rating. Click here to see.
Poorly-rated. Like or Dislike:
0
3
EdgarLO says:
April 12, 2010 at 4:35 am (UTC 5.5)
did yu hear about new iphoen 4.0? For me, one of the best features in iPhone OS 4.0 is its multitasking feature. And you?
tnx
Like or Dislike:
0
2
Clemente Phanthanouvon says:
April 14, 2010 at 2:24 am (UTC 5.5)
Amazing Dude, I didn’t knew that, thanks.
Like or Dislike:
0
1
Marc Curreri says:
April 21, 2010 at 7:03 am (UTC 5.5)
Looks like these guys have plenty of outsourcing opportunities available.
Like or Dislike:
0
2
San Diego short sales says:
April 24, 2010 at 9:46 am (UTC 5.5)
Thanks!
Like or Dislike:
0
1
Robbie Gentili says:
April 27, 2010 at 6:51 pm (UTC 5.5)
Keep on blogging! its getting through the tough times that make you stronger and then the good times will follow, keep writing about your experiences and we should all pull together.
Like or Dislike:
0
2
ochrona says:
April 28, 2010 at 6:49 pm (UTC 5.5)
Yes, that is true, I agree with you, but I am not sure if there are no other options.
Like or Dislike:
0
0
business grants says:
May 2, 2010 at 4:46 pm (UTC 5.5)
Keep up the good writing
Like or Dislike:
0
1
Mozelle Hayn says:
May 3, 2010 at 12:47 pm (UTC 5.5)
Your post caught my eye. Thanks for posting this information.
Like or Dislike:
0
1
free gadgets says:
May 11, 2010 at 3:50 am (UTC 5.5)
I was just searching google and found your blog, very nice read.
Like or Dislike:
0
0
Annabell Faretra says:
May 13, 2010 at 10:36 am (UTC 5.5)
I completely agree with the above comment, the internet is with a doubt growing into the most important medium of communication across the globe and its due to sites like this that ideas are spreading so quickly.
Like or Dislike:
0
0
Shela Graven says:
May 19, 2010 at 12:13 pm (UTC 5.5)
Really nice article! Your writing is so fresh in comparison to most other bloggers. Thank you for posting when you get the chance to, I’ll be sure to subscribe!
Like or Dislike:
0
0
zaklady bukmacherskie says:
May 27, 2010 at 5:24 pm (UTC 5.5)
Great info, thanks for useful article. I am waiting for more
Like or Dislike:
0
0
Donya Whetsel says:
May 27, 2010 at 8:20 pm (UTC 5.5)
Thank you for another informative blog. Where else could I get that kind of info written in such a perfect way? I have a project that I am just now working on, and I have been on the look out for such information.
Like or Dislike:
0
0
Bradly Avona says:
May 28, 2010 at 6:15 am (UTC 5.5)
hey,Superb article dude! i am Tired of using RSS feeds and do you use twitter?so i can follow you there:D.
PS:Do you thought to be putting video to the blog to keep the readers more interested?I think it works.Best regards, Bradly Avona
Like or Dislike:
0
0
gumpert says:
May 28, 2010 at 5:35 pm (UTC 5.5)
nice copy of the ibatis documentation. do you plan to stop commenting/cheering your own blog?
Like or Dislike:
0
0
Tobias Norg says:
May 30, 2010 at 12:28 pm (UTC 5.5)
Hi there, awesome site. I thought the topics you posted on were very interesting
Like or Dislike:
0
0
Andrew A. Sailer says:
June 30, 2010 at 5:57 pm (UTC 5.5)
Hi there may I use some of the information here in this post if I provide a link back to your site?
Like or Dislike:
0
0
Kredit ohne Schufaauskunft says:
April 22, 2011 at 2:33 am (UTC 5.5)
I precisely wished to appreciate you once more. I’m not certain the things that I could possibly have accomplished in the absence of the type of suggestions shared by you directly on such a situation. Completely was a real daunting matter for me personally, however , looking at a skilled avenue you handled it forced me to weep over joy. I’m just thankful for your work as well as pray you find out what a powerful job you are always putting in instructing men and women using your webblog. I’m certain you’ve never got to know all of us.
Like or Dislike:
0
0