ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Leucht, Axel" <Axel.Leu...@prodv.de>
Subject Document root element is missing
Date Mon, 04 Sep 2006 11:47:18 GMT
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

Does anybody know what's going wrong here? My environment is  JDK 1.4.2_07. 

Here are both xml-Files.

	<?xml version="1.0" encoding="UTF-8" ?>
	<!DOCTYPE sqlMapConfig
	PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN"
	<!-- Always ensure to use the correct XML header as above! -->
	<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>"/>
	<!-- 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" />
	<?xml version="1.0" encoding="UTF-8" ?>
	<!DOCTYPE sqlMap
	PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN"
	<select id="getPerson" resultClass="examples.domain.Person">
	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
	WHERE PER_ID = #value#
	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
				} catch (IOException e) {
					// TODO Auto-generated catch block

View raw message