ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davypulin...@telenet.be
Subject Re: Please help me.
Date Fri, 01 Jun 2007 10:40:01 GMT
Hellow,

I dont see the light in this simple small application, would anyone help me.
In the sqlmap you see $schema$, I would to get the name testschema written in java code in
the $schema$

Sqlmapconfig.xml

<?xml version="1.0" encoding="UTF-8" ?>  
 <!DOCTYPE sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN"  
 "http://www.ibatis.com/dtd/sql-map-config-2.dtd"> 
 
<sqlMapConfig> 
    <transactionManager type="JDBC"> 
        <dataSource type="SIMPLE"> 
			<property name="JDBC.Driver" value=".."/>
			<property name="JDBC.ConnectionURL" value=".."/>
			<property name="JDBC.Username" value=".."/>
			<property name="JDBC.Password" value=".."/>
		</dataSource>
    </transactionManager>
    <sqlMap resource="SqlMap.xml"/> 
 </sqlMapConfig>



SqlMap.xml

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD sql Map 2.0//EN"
	"http://ibatis.apache.org/dtd/sql-map-2.dtd">

<sqlMap>
	<select id="departmentcode" remapResults="true" parameterClass="string" resultClass="hashmap">
	select departmentcode from $schema$.DEPARTMENT
	</select>	
</sqlMap>



Java code

import com.ibatis.sqlmap.client.*;
import com.ibatis.common.resources.Resources;
import java.io.Reader;
import java.util.List;

public class Ibatis {

    public static void main(String[] args) throws Exception {
        String schema = "testschema";
	String resource = "SqlMapConfig.xml";
	Reader reader = Resources.getResourceAsReader(resource);		
			SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);
		List list = sqlMap.queryForList("departmentcode");
		System.out.println("Er werden " + list.size() + " Records weerhouden aan uw zoekcriteria.");
		System.out.println("                                                                   
                                 ");
		for (int i = 0; i <list.size(); i++) {
			System.out.println(list.get(i));
		}
    }
}

>----- Oorspronkelijk bericht -----
>Van: Nathan Maves [mailto:nathan.maves@gmail.com]
>Verzonden: donderdag, mei 31, 2007 11:36 PM
>Aan: user-java@ibatis.apache.org
>Onderwerp: Re: Please help me.
>
>Pretty simple actually,
>
>you can pass a string (non binding) variable into a sqlmap
>
>example
>
><sqlmap ......>
>   select * from $schema$.person where id = #id#
></sqlmap>
>
>Note the use of $$ and ##.  The $$ uses a string substitution and not a jdbc
>parameter.
>
>
>On 5/31/07, Davy Pulinckx <davypulinckx@telenet.be> wrote:
>>
>>  Hellow
>>
>>
>>
>> I have a question on how I would change my application in the best
>> possible way.
>>
>> I will first explain the situation.
>>
>> There is a web-application build with JBuiler, I use weblogic to deploy te
>> application and I uses .xml properties files each different for each
>> environment (integration, acceptation and production) and the database is
>> db2
>>
>> At this time I uses JDBC and the sql query is written in the source file
>> for example :
>>
>>
>>
>> private final String select1 = "SELECT * FROM "+ javaFile.schemaName +
>> etc…..
>>
>>
>>
>> Now the problem is, the application uses properties files, in the
>> properties file I store for example the db2 schema, url's, etc…
>>
>> My question is, how would I made this to ibatis
>>
>> -          How cane I get the name of the db2 schema stored in the xml
>> propertie-file into Ibatis xml file sow I cane execute my sql file written
>> in ibatis => SELECT * FROM "+ *javaFile.schemaName* + etc…..
>>
>> -          An other problem for me is, the application uses weblogic, in
>> the console are datasources and connectionpools created. I read many
>> examples and always I see username and password written in the .xml config
>> file of ibatis. Butt is there a way to use the weblogic configuration
>> (datasource, connectionpool).
>>
>>
>>
>> I now I ask mutch, butt I just changed to another employee the application
>> is written during a few years thru another person, and now I must learn
>> everything in a few months and I must migrate the application to ibatis in a
>> few weeks, and I don't now what I must do to make this work, every help is
>> good, examples, tutorials, etc….
>>
>> Would you please help me, please.
>>
>>
>>
>> Sorry for my English, I'm Dutch (Europe)
>>
>>
>>
>>
>>
>> Or is there another way to configurate this.
>>
>>
>>
>>
>>
>>
>>
>



Mime
View raw message