ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "André Rodrigues Pena" <andre.u...@gmail.com>
Subject Problems compiling
Date Mon, 29 Jan 2007 11:25:48 GMT
Hi all,

I'm new to iBatis, this is my first project. I'm trying to use it with a
JDBC driver provided by Microsoft to access MS SQL 2005. Every time I try to
run it on Eclipse I get the same error message: "Could not find the main
class. Program will exit". This error is often retrieved when you try to
execute a JAR file that hasn't it's MANIFEST.MF file set to specify the main
class. It's not my case. Also there aren't version compatibility issues.

I thought this error could have been generated due to mis-configuration.
While configuring the transaction manager in the XML , I didn't find the
list of available properties so that I can set what I need. So I set the
properties I thought would be available:

Here is the source-code of my 3 files: (They are all at the same package and
classpath can find packages properly)

***** SqlMapsConfig.XML *****

<?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">

<sqlMapConfig>

  <transactionManager type="JDBC" commitRequired="false">
    <dataSource type="SIMPLE">
      <property name="JDBC.Driver" value="
com.microsoft.sqlserver.jdbc.SQLServerDriver"/>
      <property name="JDBC.Username" value="sa"/>
      <property name="JDBC.Password" value="ph4r400h"/>
      <property name="JDBC.ServerName" value="localhost"/>
      <property name="JDBC.DatabaseName" value="PDV"/>
      <property name="JDBC.PortNumber" value="1455"/>
    </dataSource>
  </transactionManager>

<sqlMap resource="Translation.xml"/>

</sqlMapConfig>

***** Translation.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 namespace="Translation">


  <resultMap id="TranslationResult" class="Translation">
    <result property="id" column="id"/>
    <result property="label" column="label"/>
  </resultMap>

  <select id="selectAllTranslations" resultMap="TranslationResult">
    SELECT * FROM _translations
  </select>

</sqlMap>

***** Tests.java *****

import java.io.IOException;
import java.io.Reader;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;

public class Tests {
    private static SqlMapClient sqlMapper;
     static {
            try {
              Reader reader = Resources.getResourceAsReader("
SqlMapConfig.xml");
              sqlMapper = SqlMapClientBuilder.buildSqlMapClient(reader);
              reader.close();
            } catch (IOException e) {
              // Fail fast.
              throw new RuntimeException("Something bad happened while
building the SqlMapClient instance." + e, e);
            }
          }

    public static List selectAllTranslations() throws SQLException {
        return sqlMapper.queryForList("selectAllTranslations");

    }

    public static void main(String args[]) {
        ArrayList myList;
        try {
            myList = new ArrayList(Tests.selectAllTranslations());
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}

Does anybody know the problem? Any tips are welcome,
Thanks in advance.

-- 
André Rodrigues Pena

Mime
View raw message