Here is my snipet that works:
static { try {
Reader reader = Resources.getResourceAsReader("properties/sql-map-config.xml");
_sqlMap = XmlSqlMapBuilder.buildSqlMap(reader);
_sqlMap.setCurrentDataSourceName("ids");
log.debug("we have a connection pool!");
}
I am not sure where you might be stuck, can you put a few debugs in?
.V
Peyathevar, Santhi {PBG} wrote:
Vic,
1.i do not need a web app. Only, simple java app.
2.I tried both Dbcp and SimpleDataSourceFactory.
both give null. Connecting to oracle database.
I know it is connecting to the database, because it complains if i leave syntax errors.
************************************ This is the sample that i am trying to run - from IBatis Web site: ************************************ SqlMapConfigExample.xml
<datasource name="basic" default = "true"
factory-class="com.ibatis.db.sqlmap.datasource.SimpleDataSourceFactory"> <property name="JDBC.Driver" value="${driver}"/> <property name="JDBC.ConnectionURL" value="${url}"/> <property name="JDBC.Username" value="${username}"/> <property name="JDBC.Password" value="${password}"/> </datasource>
<sql-map resource="examples/sqlmap/maps/Account.xml" />
************************************
Account.xml
<result-map name="indexed-account-result2" class="examples.domain.Account"> <property name="id" column="ACC_ID" columnIndex="1"/> <property name="firstName" column="ACC_FIRST_NAME" columnIndex="2"/> <property name="lastName" column="ACC_LAST_NAME" columnIndex="3"/> </result-map>
<mapped-statement name="getAccount" cache-model="account-cache" result-map="indexed-account-result2"> select ACC_ID, ACC_FIRST_NAME, ACC_LAST_NAME from ACCOUNT where ACC_ID = #value# </mapped-statement>
************************************* SqlMapConfigExample.java (Don't i have to use the datasource name "basic" anywhere ?
static {
Reader reader = Resources.getResourceAsReader("examples/sqlmap/maps/SqlMapConfigExample.xml" ); sqlMap = XmlSqlMapBuilder.buildSqlMap(reader); }
*********************************** QueryForListExample.java
SqlMap sqlMap = SqlMapConfigExample.getSqlMap();
try {
sqlMap.startTransaction();
Account account = (Account)
sqlMap.executeQueryForObject("getAccount", new Integer(1));
sqlMap.commitTransaction();
}
************************************
Sorry about the long email
Santhi
************************************
-----Original Message----- From: Vic Cekvenich [mailto:[EMAIL PROTECTED] Sent: Thursday, October 16, 2003 3:49 PM To: [EMAIL PROTECTED] Subject: Re: [MVC-Programmers] IBatis returns null
It's best to use JNDI container DataSource pools, howerver:
<datasource name="ids"
factory-class="com.ibatis.db.sqlmap.datasource.SimpleDataSourceFactory" default="true">
<property name="JDBC.Driver" value="org.postgresql.Driver"/>
<property name="JDBC.ConnectionURL" value="jdbc:postgresql://localhost:5432/bp?autoReconnect=true"/>
<property name="JDBC.Username" value="bpuser"/>
<property name="JDBC.Password" value="changeme"/>
</datasource>
aboove is a sample iBatis pool. I think that was your question. From there, it is just standard iBatis.
.V
Peyathevar, Santhi {PBG} wrote:
All:
1.I am trying to use IBatis for running some SQL
from simple java code.
2.using DbcpDataSourceFactory
3.It connects to the database but the result is null
Can anybody help?
Santhi
_______________________________________________ MVC-Programmers mailing list [EMAIL PROTECTED] http://www.basebeans.net:8080/mailman/listinfo/mvc-programmers
_______________________________________________ MVC-Programmers mailing list [EMAIL PROTECTED] http://www.basebeans.net:8080/mailman/listinfo/mvc-programmers _______________________________________________ MVC-Programmers mailing list [EMAIL PROTECTED] http://www.basebeans.net:8080/mailman/listinfo/mvc-programmers
_______________________________________________ MVC-Programmers mailing list [EMAIL PROTECTED] http://www.basebeans.net:8080/mailman/listinfo/mvc-programmers