logo       


Re: Strange Problem..: msg#00489

Subject: Re: Strange Problem..
<transactionManager type="JDBC" commitRequired="true">

On 8/25/05, Eduardo Lobo <elobo@xxxxxxxxxx> wrote:
>  
>  Thanks for the answer,
>  
>  This is the SQL config that I'm using:
>  
>  <?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>
>      
>      <settings
>          cacheModelsEnabled="false"
>          enhancementEnabled="true"
>          lazyLoadingEnabled="true"
>          maxRequests="32"
>          maxSessions="10"
>          maxTransactions="5"
>          useStatementNamespaces="false"/>
>      
>      <transactionManager type="JDBC" commitRequired="true" >
>          <dataSource type="SIMPLE">
>              <property name="JDBC.Driver"
> value="net.sourceforge.jtds.jdbc.Driver"/>
>              <property name="JDBC.ConnectionURL"
> value="jdbc:jtds:sqlserver://192.168.1.20:1433/Database"/>
>              <property name="JDBC.Username" value="user"/>
>              <property name="JDBC.Password" value="*****"/>
>              <property name="JDBC.DefaultAutoCommit" value="true"/>
>          </dataSource>
>      </transactionManager>
>      
>      <sqlMap resource="Person.xml"/>
>      
>  </sqlMapConfig>
>  
>  Could you tell me, please, what I need to change to make this work?
> 
>  
>  
>  Larry Meadors wrote: 
>  The transaction's being rolled back, it looks like.
> 
> Change your transaction manager to commitRequired="true" and i think
> it will work.
> 
> On a related note..you do know that you can do all of that without a
> stored proc, right?
> 
> <insert ...>
>  insert Person (Name) values (#name#)
>  <selectKey property="id">
>  select SCOPE_IDENTITY()
>  </selectKey>
> </insert>
> 
> Insert the record, set the id property to the generated key. Done. :-)
> 
> Larry
> 
> 
> On 8/25/05, Eduardo Lobo <elobo@xxxxxxxxxx> wrote:
>  
>  
>  Hi,
> 
> My problem is this:
> 
> I create this SP(in SQL Server 2000):
> 
> create procedure create_person
> @name varchar(80)
> as
> begin
>  declare @id int
> 
>  insert Person (Name)
>  values (@name)
> 
>  Set @id = SCOPE_IDENTITY()
> 
>  select Id, Name
>  from Person
>  where Id = @id
> end
> GO
> 
> 
> This is the XML Map:
> 
> <?xml version="1.0" encoding="UTF-8" ?>
> <!DOCTYPE sqlMap
>  PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN"
>  "http://www.ibatis.com/dtd/sql-map-2.dtd";>
> 
> <sqlMap namespace="Person">
> 
>  <!-- ///////////////Type Aliases/////////////// -->
>  <typeAlias alias="Map" type="java.util.Map"/>
>  <typeAlias alias="Person" type="Person"/>
>  <!-- ///////////////Type Aliases/////////////// -->
> 
>  <!-- ///////////////Result Maps/////////////// -->
>  <resultMap id="Person_Result" class="Person">
>  <result property="id" column="Id"/>
>  <result property="name" column="Name"/>
>  </resultMap>
>  <!-- ///////////////Result Maps/////////////// -->
> 
>  <!-- ///////////////Procedues/////////////// -->
>  <procedure id="create_person" resultMap="Person_Result"
> parameterClass="Map">
>  {call create_person (#name#)}
>  </procedure>
>  <!-- ///////////////Procedues/////////////// -->
> 
> </sqlMap>
> 
> 
> This is the java code:
> 
> SqlMapClient sqlMap = null;
>  try {
>  String file = "SQLConfigMap.xml";
>  Reader reader = Resources.getResourceAsReader(file);
>  sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);
> 
>  HashMap params = new HashMap();
>  params.put("name", "David");
>  Object obj = sqlMap.queryForObject("create_person", params);
>  System.out.println("create_person: " + obj);
> 
>  } catch (Exception e) {
>  System.out.println(e.getMessage());
>  }
> 
> 
> Results:
> 
> Finally when I print the result I got the new Record info,
> 
> Person: id = 1, name = David
> 
> That's fine, but when I check the Table there's not record...
> 
> But the strange is that it returns the mapped object with the new data,
> like if it was successfully inserted.
> 
> The "Id" field from the table Person is Identity (automatic sequential),
> and if I try to insert the record again then a I get the next "Id"
> (Person: id = 2, name = David), but again nothing is in the table..
> 
> 
> Thanks for the help.
> 
> Eduardo Lobo
> 
> 
> 
> 
> 
> 
>  
>  
>  
>



Ruby Jobs
Java Jobs
Jobs in California
more...
what
job title, keywords
where
city, state, zip
jobs by job search
Search:
Java, servers, webhosting, windows, cisco ...
more...
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
encryption.gpg....    ietf.rfc822/199...    freebsd.devel.i...    lang.haskell.li...    mail.squirrelma...    web.zope.plone....    yellowdog.gener...    text.xml.xalan....    recreation.phot...    kde.devel.educa...    hardware.bus.ca...    printing.ghosts...    voip.peering/20...    assembly/2006-0...    org.user-groups...    culture.interne...    network.i2p/200...    boot-loaders.ya...    xfree86.render/...    qnx.openqnx.dev...    jakarta.velocit...    user-groups.pal...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe