随便来个完整的小例子就行.  什么驱动啊什么的  说下吧..
     BT老师不让用JDBC...

解决方案 »

  1.   

    没用过“SQLJ..”这里倒是有些 SQLJ 的资料http://oreilly.com/pub/ct/46不过我没找到“SQLJ..”的资料
      

  2.   

    上baidu网上去google一下 你就知道
      

  3.   

    http://www.ibm.com/developerworks/cn/data/library/techarticles/dm-0412cline/index.html
    具体看看上面地址吧包含主方法的 Java 类
    <![CDATA[
    /*
     * Created on Nov 27, 2004
     *
     */
    package com.ibm.sqlj.main;
    import com.ibm.sqlj.Select;
    /**
     * @author Owen Cline
     *
     */
    public class SQLJJave {
    public static void main(String[] args) {
    Select select = new Select();
    select.selectEmployee("000110");
    }
    }
    ]]>
     
    <![CDATA[
    /*
     * Created on Nov 27, 2004
     *
     */
    package com.ibm.sqlj;
    import java.sql.*;
    import sqlj.runtime.ref.*;
    /**
     * @author Owen Cline
     *
     */
    public class Select {
    // First, load the JDBC driver
    static
    {   
    try
    {   
    Class.forName ("COM.ibm.db2.jdbc.app.DB2Driver").newInstance ();

    catch (Exception e)
    {   System.out.println ("\n  Error loading DB2 Driver...\n");
    System.out.println (e);
    System.exit(1);
    }
    }
    public void selectEmployee(String empNo) {
    Connection con = null;          
    DefaultContext ctx = null;            
    try 
    {
    String firstName = null;
    String lastName = null;
    // use the DB2 SAMPLE database
    String url = "jdbc:db2:SAMPLE";

    // Get the connection
    con = DriverManager.getConnection(url);  
    // Set the default context
    ctx = new DefaultContext(con);            
    DefaultContext.setDefaultContext(ctx);
    // Lookup the employee given the employee number
    #sql { SELECT FIRSTNME, LASTNAME INTO :firstName, :lastName
       FROM EMPLOYEE
       WHERE EMPNO = :empNo } ;
    System.out.println ("Employee " + firstName + "  " + lastName);
    ctx.close();
    con.close();
    }
    catch( Exception e )
    {
    System.out.println (e);
    }
    }
    }
    ]]>