• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem in saving data using IBATIS + Spring

 
ujjwal soni
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am using IBatis with spring for my website. I am getting the below error while i try to save the data.

java.lang.IllegalArgumentException: No SqlMapClient specified

Below are the contents for RegisterSQLMap.java

public class RegisterSqlMap extends SqlMapClientDaoSupport {


private static SqlMapClient sqlMapper;


static {
try {
Reader reader = Resources.getResourceAsReader("my/Dao/Admin/SqlMap/Map/RegisterMap.xml");
sqlMapper = SqlMapClientBuilder.buildSqlMapClient(reader);
reader.close();
} catch (IOException e) {
// Fail fast.
throw new RuntimeException("Something bad happened while building the SqlMapClient instance." + e, e);
}
}

public boolean addData(SignUpCommand suc)
{
getSqlMapClientTemplate().insert("joinNow", suc);
return true;

}

}


Below are the contents for RegisterSQLMap.java

public class RegisterSqlMap extends SqlMapClientDaoSupport {


private static SqlMapClient sqlMapper;


static {
try {
Reader reader = Resources.getResourceAsReader("my/Dao/Admin/SqlMap/Map/RegisterMap.xml");
sqlMapper = SqlMapClientBuilder.buildSqlMapClient(reader);
reader.close();
} catch (IOException e) {
// Fail fast.
throw new RuntimeException("Something bad happened while building the SqlMapClient instance." + e, e);
}
}

public boolean addData(SignUpCommand suc)
{
getSqlMapClientTemplate().insert("joinNow", suc);
return true;

}

}


Regards,

Ujjwal Soni
<Baroda>
 
ujjwal soni
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have solved this problem. The problem was that i had not defined any defination for SQLClient in xml files. Writing the below code solved my problem.

bean id="sqlMapClient"
class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation">
<value>WEB-INF/config/SqlMapConfig.xml</value>
</property>
<property name="useTransactionAwareDataSource">
<value>true</value>
</property>
<property name="dataSource">
<ref bean="dataSource"/>
</property>
</bean>

Regards,

Ujjwal B Soni
<Baroda Gujarat India>
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!