ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cristiano Monteiro dos Santos <csan...@polimed.com.br>
Subject RES: Ibatis DAO XML problem
Date Mon, 19 Jun 2006 18:39:53 GMT
It's working like a charm... Thanks for your help, Jeff! :D
 
Regards,
Cristiano

-----Mensagem original-----
De: Jeff Butler [mailto:jeffgbutler@gmail.com]
Enviada em: segunda-feira, 19 de junho de 2006 14:44
Para: user-java@ibatis.apache.org
Assunto: Re: Ibatis DAO XML problem


Your code should look something like this:
 
private MyDAO myDao;
 
protected void setUp() throws Exception {
  Reader reader = Resources.getResourceAsReader("dao.xml");
  daoManager = DaoManagerBuilder.buildDaoManager(reader);
  
  this.myDao = (MyDAO) daoManager.getDao(MyDAO.class);
}
 
 
Jeff Butler


 
On 6/19/06, Cristiano Monteiro dos Santos < csantos@polimed.com.br
<mailto:csantos@polimed.com.br> > wrote: 

Guess that answers to my previous email! I'll look into that more carefully.
 
Thanks a lot Jeff!
 
Regards,
Cristiano


-----Mensagem original-----
De: Jeff Butler [mailto: jeffgbutler@gmail.com
<mailto:jeffgbutler@gmail.com> ]

Enviada em: segunda-feira, 19 de junho de 2006 14:29

Para: user-java@ibatis.apache.org <mailto:user-java@ibatis.apache.org> 

Assunto: Re: Ibatis DAO XML problem




Wow - I just saw the problem.  You're passing an sqlmapconfig xml file to
the dao builder.  That won't work at all.  I think you need to read the DAO
documentation to see how to configure and access iBATIS DAOs.
 
Jeff Butler

 
On 6/19/06, Jeff Butler < jeffgbutler@gmail.com
<mailto:jeffgbutler@gmail.com> > wrote: 


That's correct - but you probably have another configuration file for the
DAOs (typically called dao.xml).  I think the error is happening with that
file.  It's DOCTYPE should look like this:
 
<!DOCTYPE daoConfig
    PUBLIC "-//ibatis.apache.org//DTD DAO Configuration 2.0//EN"
    " http://ibatis.apache.org/dtd/dao-2.dtd
<http://ibatis.apache.org/dtd/dao-2.dtd> ">
 
Three different types of XML files, three different DOCTYPEs that need to be
correct.

 
Jeff Butler

 
On 6/19/06, Cristiano Monteiro dos Santos <  <mailto:csantos@polimed.com.br>
csantos@polimed.com.br> wrote: 

Hey again, Jeff!
 
Here goes the DOCTYPE from my sqlMap':
 

<?

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
<http://ibatis.apache.org/dtd/sql-map-2.dtd> " >
I believe this is correct, according to the iBATIS site. The version I'm
using is the zip version of iBATIS_DBL-2.1.7.597.
 
Thanks,
CMS
 


-----Mensagem original-----
De: Jeff Butler [mailto: jeffgbutler@gmail.com
<mailto:jeffgbutler@gmail.com> ]

Enviada em: segunda-feira, 19 de junho de 2006 13:54

Para: user-java@ibatis.apache.org <mailto:user-java@ibatis.apache.org> 
Assunto: Re: Ibatis DAO XML problem 




Sorry, you're right - it's a parser connect problem, not a database connect
problem.  iBATIS shouldn't try to connect to the Internet for parsing if the
DOCTYPEs are right, and you have the latest version of iBATIS. 
 
The error is coming wile try to parse the dao.xml.  Make sure that the
DOCTYPE in your dao.xml is correct too (from the iBATIS home page).  And
make sure you are using the latest version of iBATIS.
 
Jeff Butler

 
On 6/19/06, Cristiano Monteiro dos Santos <  <mailto:csantos@polimed.com.br>
csantos@polimed.com.br> wrote: 

Hi Jeff.
 
Here's the properties file:
 
driver=com.informix.jdbc.IfxDriver

url=jdbc:informix-sqli://10.11.101.6:668/polimed4:INFORMIXSERVER=df06

username=user

password=pass

The JDBC jar is in the Eclipse classpath. I'm not sure it's a connection
releated issue, according to the stack trace. Anyways, here you go.
 
Thanks!
 
-CMS
 

-----Mensagem original-----
De: Jeff Butler [mailto:  <mailto:jeffgbutler@gmail.com>
jeffgbutler@gmail.com]
Enviada em: segunda-feira, 19 de junho de 2006 12:20

Para: user-java@ibatis.apache.org <mailto:user-java@ibatis.apache.org> 

Assunto: Re: Ibatis DAO XML problem

 


I'm pretty certain this is related to your database connection settings.
Send along a copy of your SqlMapConfig.properties file.  Probably something
is wrong there.
 
Jeff Butler

 
On 6/19/06, Cristiano Monteiro dos Santos <  <mailto:csantos@polimed.com.br>
csantos@polimed.com.br> wrote: 

The fixed doctipe I'm using now is:
<?

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
<http://ibatis.apache.org/dtd/sql-map-config-2.dtd> "> 

But still getting the error. Ideas?

Thanks!


-----Mensagem original-----
De: Niels Beekman [mailto: n.beekman@wis.nl <mailto:n.beekman@wis.nl> ]

Enviada em: segunda-feira, 19 de junho de 2006 11:57

Para: user-java@ibatis.apache.org <mailto:user-java@ibatis.apache.org> 
Assunto: RE: Ibatis DAO XML problem 





If you fixed the DOCTYPE declaration, it should all work, do you still get
the same exception?

 


  _____  


From: Cristiano Monteiro dos Santos [mailto: csantos@polimed.com.br
<mailto:csantos@polimed.com.br> ] 
Sent: maandag 19 juni 2006 16:35 
To: ' user-java@ibatis.apache.org <mailto:user-java@ibatis.apache.org> '
Subject: RES: Ibatis DAO XML problem

 

This information is closer to the one I get from google about this problem.
How can I solve this? Also, I've already fixed the other observations from
Jeff. 

 

Thanks,

CMS

-----Mensagem original-----
De: Niels Beekman [mailto:  <mailto:n.beekman@wis.nl> n.beekman@wis.nl]
Enviada em: segunda-feira, 19 de junho de 2006 11:29
Para: user-java@ibatis.apache.org <mailto:user-java@ibatis.apache.org> 
Assunto: RE: Ibatis DAO XML problem 

I believe the "connection refused" is actually the result of the wrong
DOCTYPE declaration, the DTD cannot be resolved. 

 

Niels

 


  _____  


From: Jeff Butler [mailto: jeffgbutler@gmail.com
<mailto:jeffgbutler@gmail.com> ] 
Sent: maandag 19 juni 2006 16:25
To: user-java@ibatis.apache.org <mailto:user-java@ibatis.apache.org> 
Subject: Re: Ibatis DAO XML problem

 

The cause of error is "connection refused". This implies that there is
something wrong with your database connection settings. 

 

Other things I noticed (these are not causing your error, but could cause
other errors):

 

1. You need to specify useStatementNamespaces="true".  You'll not get far
with Abator if you disable namespaces.

 

2. The DOCTYPE declaration is wrong - please see the iBATIS home page for
the new DOCTYPE declarations.

 

Jeff Butler

 

On 6/19/06, Cristiano Monteiro dos Santos <  <mailto:csantos@polimed.com.br>
csantos@polimed.com.br> wrote: 

Hi there!

I'm new to iBATIS and I'm having problem on executing JUnit tests. I'm using
Abator for some code generation for a simple CRUD app I have to build. I've 
mapped all the abator's xml in the SqlMapConfig.xml, like this:

<?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
<http://www.ibatis.com/dtd/sql-map-config-2.dtd> ">

<sqlMapConfig> 

       <properties resource="SqlMapConfig.properties " />

       <settings cacheModelsEnabled="true" enhancementEnabled="true"
               lazyLoadingEnabled="true" maxRequests="32" maxSessions="10" 
               maxTransactions="5" useStatementNamespaces="false" />

       <typeAlias alias="order" type="testdomain.Order" />

       <transactionManager type="JDBC"> 
               <dataSource type="SIMPLE">
                       <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>
       </transactionManager>

       <sqlMap
resource="br/com/polimed/ibatis/polimed4/model/informix_tbcartaocategoria_Sq
lMap.xml" />
       <sqlMap
resource="br/com/polimed/ibatis/polimed4/model/informix_tbcartaoespec_SqlMap
.xml" />
       <sqlMap
resource="br/com/polimed/ibatis/polimed4/model/informix_tbespecialidade_SqlM

ap.xml" />

</sqlMapConfig>

But as I try to configure my DAO like this:
Reader reader = Resources.getResourceAsReader( "SqlMapConfig.xml" );
Tb301autogeradoDAO dao = new Tb301autogeradoDAOImpl( 
DaoManagerBuilder.buildDaoManager( reader ) );

I receive this error:

com.ibatis.dao.client.DaoException: Error while configuring DaoManager.
Cause: com.ibatis.common.exception.NestedRuntimeException: XML Parser Error.

Cause: java.net.ConnectException: Connection refused: connect
Caused by: com.ibatis.common.exception.NestedRuntimeException: XML Parser
Error.  Cause: java.net.ConnectException: Connection refused: connect
       at 
com.ibatis.dao.engine.builder.xml.XmlDaoManagerBuilder.buildDaoManager(XmlDa
oManagerBuilder.java:129)
       at
com.ibatis.dao.client.DaoManagerBuilder.buildDaoManager(DaoManagerBuilder.ja
va:59)
       at 
br.com.polimed.ibatis.sim.dao.Tb301autogeradoDAOImplTest.setUp(Tb301autogera
doDAOImplTest.java:17)
       at junit.framework.TestCase.runBare(TestCase.java:125)
       at junit.framework.TestResult$1.protect (TestResult.java:106)
       at junit.framework.TestResult.runProtected(TestResult.java:124)
       at junit.framework.TestResult.run(TestResult.java:109)
       at junit.framework.TestCase.run(TestCase.java:118) 
       at junit.framework.TestSuite.runTest(TestSuite.java:208)
       at junit.framework.TestSuite.run(TestSuite.java:203)
       at
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3T

estReference.java:128)
       at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:3
8)
       at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRu
nner.java:460)
       at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRu
nner.java:673)
       at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.
java:386)
       at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner
.java:196)
Caused by: com.ibatis.common.exception.NestedRuntimeException: XML Parser
Error.  Cause: java.net.ConnectException : Connection refused: connect
       at
com.ibatis.dao.engine.builder.xml.XmlDaoManagerBuilder.getDoc(XmlDaoManagerB
uilder.java:320)
       at
com.ibatis.dao.engine.builder.xml.XmlDaoManagerBuilder.buildDaoManager
(XmlDa
oManagerBuilder.java:88)
       ... 15 more

Caused by:
com.ibatis.common.exception.NestedRuntimeException: XML Parser Error.
Cause: java.net.ConnectException: Connection refused: connect
       at 
com.ibatis.dao.engine.builder.xml.XmlDaoManagerBuilder.getDoc(XmlDaoManagerB
uilder.java:320)
       at
com.ibatis.dao.engine.builder.xml.XmlDaoManagerBuilder.buildDaoManager(XmlDa
oManagerBuilder.java:88) 
       at
com.ibatis.dao.client.DaoManagerBuilder.buildDaoManager(DaoManagerBuilder.ja
va:59)
       at
br.com.polimed.ibatis.sim.dao.Tb301autogeradoDAOImplTest.setUp(Tb301autogera
doDAOImplTest.java:17) 
       at junit.framework.TestCase.runBare(TestCase.java:125)
       at junit.framework.TestResult$1.protect(TestResult.java:106)
       at junit.framework.TestResult.runProtected(TestResult.java:124)
       at junit.framework.TestResult.run(TestResult.java:109)
       at junit.framework.TestCase.run(TestCase.java:118)
       at junit.framework.TestSuite.runTest(TestSuite.java:208)
       at junit.framework.TestSuite.run (TestSuite.java:203)
       at
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3T
estReference.java:128)
       at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java
:3
8)
       at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRu
nner.java:460)
       at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRu
nner.java :673)
       at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.
java:386)
       at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner
.java:196)


Any idea of what's happening? I've already searched Google and Jira for
those, with no concrete answer.

TIA!

Regards,
Cristiano

 







Mime
View raw message