ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Butler" <jeffgbut...@gmail.com>
Subject Re: Document root element is missing
Date Mon, 04 Sep 2006 12:53:20 GMT
You must be looking at an old version of the tutorial, and possibly using an
old version of iBATIS.  The DOCTYPEs have changed.  You can get the correct
ones from the iBATIS home page, or from a newer version of the tutorial.

Also, make sure you are using the latest version of iBATIS.

If making all those changes doesn't fix it, then please attach a stack
trace.

Jeff Butler



On 9/4/06, Leucht, Axel <Axel.Leucht@prodv.de> wrote:
>
> I'm currently trying to setup ibatis for the first time.
>
> I copied the SqlMapConfig.xml from the tutorial, tweaked the jdbc
> connection parameter to match my environment, copied the Person.xml from
> the tutorial, created the person table in the database and then tried to
> start a simple query as in the tutorial.
>
> But iBatis throws a "org.xml.sax.SAXParseException: Document root element
> is missing" at startup time..
>
> Does anybody know what's going wrong here? My environment is  JDK 1.4.2_07
> .
>
> Here are both xml-Files.
>
> 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">
>        <!-- Always ensure to use the correct XML header as above! -->
>        <sqlMapConfig>
>        <transactionManager type="JDBC" >
>        <dataSource type="SIMPLE">
>        <property name="JDBC.Driver" value="<myDriver>"/>
>        <property name="JDBC.ConnectionURL" value="<myUrl>"/>
>        <property name="JDBC.Username" value="<myUser>"/>
>        <property name="JDBC.Password" value="<myPassword>"/>
>        </dataSource>
>        </transactionManager>
>        <!-- Identify all SQL Map XML files to be loaded by this SQL map.
> Notice the paths
>        are relative to the classpath. For now, we only have one -->
>        <sqlMap resource="Person.xml" />
>        </sqlMapConfig>
> Person.xml:
>        <?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>
>        <select id="getPerson" resultClass="examples.domain.Person">
>        SELECT
>        PER_ID as id,
>        PER_FIRST_NAME as firstName,
>        PER_LAST_NAME as lastName,
>        PER_BIRTH_DATE as birthDate,
>        PER_WEIGHT_KG as weightInKilograms,
>        PER_HEIGHT_M as heightInMeters
>        FROM PERSON
>        WHERE PER_ID = #value#
>        </select>
>        </sqlMap>
> Testprog:
>        import java.io.IOException;
>        import java.io.Reader;
>        import java.sql.SQLException;
>
>        import com.ibatis.common.resources.Resources;
>        import com.ibatis.sqlmap.client.SqlMapClient;
>        import com.ibatis.sqlmap.client.SqlMapClientBuilder;
>
>        public class AppSqlConfig {
>                        private SqlMapClient sqlMap = null;
>                public static void main(String[] args) {
>                        new AppSqlConfig().run();
>                }
>
>                public void run() {
>                                try {
>                                        String resource = "SqlMapConfig.xml
> ";
>                                        Reader reader =
> Resources.getResourceAsReader (resource);
>                                        sqlMap =
> SqlMapClientBuilder.buildSqlMapClient(reader);
>                                        Integer personPk = new Integer(5);
>                                        Person person = (Person)
> sqlMap.queryForObject ("getPerson", personPk);
>                                } catch (SQLException e) {
>                                        // TODO Auto-generated catch block
>                                        e.printStackTrace();
>                                } catch (IOException e) {
>                                        // TODO Auto-generated catch block
>                                        e.printStackTrace();
>                                }
>                }
>        }
> /Axel
>
>

Mime
View raw message