应该是是jdbc驱动版本过老,某些属性不支持
换个最新的驱动试试看

解决方案 »

  1.   


    package com.aweb.test;
    import java.sql.*;
    import com.crossdb.sql.*;
    import com.spaceprogram.sql.hsqldb.*;
    import com.spaceprogram.sql.mysql.*;
    import com.thinkvirtual.sql.oracle.*;
    import com.thinkvirtual.sql.sqlserver.*;
    import com.thinkvirtual.sql.sybase.*;
    /**
     * <p>Title: CrossDB</p>
     * <p>Description: </p>
     * <p>Copyright: Copyright (c) 2002</p>
     * <p>Company: </p>
     * @author unascribed
     * @version 1.0
     */public class Tryit {  public Tryit() {
      }
      public static void main(String[] args) {    String dburl="jdbc:inetdae:127.0.0.1:1433?database=langfang&charset=GB2312";
        String dbuser="sa";
        String dbpasswd="sa";
        Connection conn=null;
        Class factory_class = null;
        com.crossdb.sql.SQLFactory factory =null;
        ResultSet rst = null;
        try {
          Class.forName("com.inet.tds.TdsDriver");
          conn =  DriverManager.getConnection(dburl,dbuser,dbpasswd);
        }
        catch (Exception ex) {
          ex.printStackTrace();
        }
        try {
          factory_class = Class.forName("com.thinkvirtual.sql.sqlserver.SQLServerFactory");
          factory = (com.crossdb.sql.SQLFactory)(factory_class.newInstance());    }
        catch (Exception ex) {
          ex.printStackTrace();
        }   SelectQuery sq = factory.getSelectQuery();
        sq.addColumn("title");
        sq.addColumn("content");
        sq.addTable("article");
        sq.addOrderBy("title");
    //    sq.setLimit(10);
        System.out.println(sq.toString());
        try {
           rst = sq.execute(conn);
           rst.next();
           System.out.println(rst.getString("title"));
        }
        catch (Exception ex) {
          ex.printStackTrace();
        }
      }
    }
      

  2.   

    package com.crossdb.sql;/**This represents a Select query.
    <p>
    /**
     * <p>Title: crossdb</p>
     * <p>Description: </p>
     * <p>Copyright: Copyright (c) 2002</p>
     * <p>Company: Space Program Inc.</p>
     * @author Travis Reeder - [email protected]
     * @version 0.1
     */import java.util.Date;
    import java.sql.ResultSet;
    import java.sql.Connection;
    import java.sql.SQLException;/*
    Should have a predefined WhereClause in which the user can add conditions to it.
     */
    public interface SelectQuery { /**  If no columns are specified (ie: addColumn never called), then default returns all columns - * @param column - column name to return in column list  */
    void addColumn(String column);
    /**  defaults to inner join @param table - table name to add to query  */
    void addTable(String table);
    /**
    @param join_type - type of join using the fields in Join.java
    @param table - table name to add to query
    @see Join  */
    void addTable(int join_type, String table); /**
    Instead of creating a Join then inserting it, since you can only have one condition on a left outer join
    to work with oracle, this is the convenient way to do it. @param join_type - type of join using the fields in Join.java
    @param table - table name to add to query
    @see Join
    @see WhereCondition
     */
    void addTable(int join_type, String table, WhereCondition cond); /** WARNING: This may get deprecated as it is unecessary considering that you
     can only have one join condition on an outer join (see requirements doc at www.crossdb.com) @param join - a join object that has all the information needed.
    @see Join  */
    void addTable(Join join);
    //void removeColumn(String column);
    //Not sure how the function thing will work cause there are too many function variations
    // Maybe have a separate function for each?  like datediff() would actually be a function
    // in a db dependent class implementation called Functions or something so you would need
    // an interface called SQLFunctions or something with all the functions in it.
    //void addColumn(int function, String column); // functions map to
    /**
     * This one will compare a string with no alterations, so in general
     * you would use this one to compare 2 columns.
     * like col1 = col2
     *
     * @see #addWhereString
     */
    void addWhereCondition(String x, int comparison, String y);
    //void addWhereCondition(
    void addWhereCondition(String x, int comparison, int y);
    void addWhereCondition(String x, int comparison, Date y);
    void addWhereCondition(String and_or, String x, int comparison, String y);
    void addWhereCondition(String and_or, String x, int comparison, int y);
    void addWhereCondition(String and_or, String x, int comparison, Date y);
    /**
     * This one will be for comparing a column against a string.
     * So the implementation should escape the string as required. (generally escaping single quotes.
     *
     * This one should wrap it with single quotes and escape it.
     *
     * ex: col1 = 'somestring'
     */
    void addWhereString(String x, int comparison, String y);
    void addWhereString(String and_or, String x, int comparison, String y); void addWhereCondition(WhereCondition cond); void addWhereClause(WhereClause wc);
    void addWhereNotNull(String col);
    void addWhereNotNull(String and_or, String col);
    void addWhereIsNull(String col);
    void addWhereIsNull(String and_or, String col); void addOrderBy(String order_by);
    void addGroupBy(String group_by);
    //void setLimit(int count);
    //void setLimit(int offset, int count); /**
    Returns the SQL statement.
     */
    //String toString(); /**
    Uses stmt to execute the query.  This is so you can keep reusing the same
    statement.  Be sure to use new statements if you want more than one resultset
    open at the same time.
     */
    CrossdbResultSet execute(java.sql.Statement stmt) throws SQLException ;
    //CrossdbResultSet
    /**
    This one takes a java.sql.Connection and then creates a statement and executes.
     */
    CrossdbResultSet execute(Connection conn) throws SQLException ; /**
    @see SQLFactory#setSchema
     */
    //public void setSchema(String schema);}
      

  3.   

    这个driver应该没有问题的,是最新的