------=_NextPart_000_000C_01C477CA.1AF41740
Content-Type: text/plain;
        charset="iso-2022-jp"
Content-Transfer-Encoding: 7bit

Now I can do the sql like 'select ....' by
CacheSys\Dev\Java\samples\CJTest7.java
sql = "SELECT ID, Name, DOB, SSN FROM Sample.Person WHERE Name %STARTSWITH
?";
cq = new CacheQuery( server, sql );
rs = cq.execute(query);
but I don't know how to sql like
sql = "delete FROM Sample.Person WHERE Name %STARTSWITH ?";

------=_NextPart_000_000C_01C477CA.1AF41740
Content-Type: application/octet-stream;
        name="CJTest7.java"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
        filename="CJTest7.java"

/*
 * CJTest7.java -- Class to test the ResultSet with Dynamic SQL
 *
 */

import com.intersys.objects.*;
import java.sql.SQLException;

/**
 * This class tests the ResultSet class with Dynamic SQL
 *
 */
public class CJTest7 {

    public static final String DEFAULT_URL =3D =
"jdbc:Cache://localhost:1972/SAMPLES";


    /**
     * The main entry point for the test program
     *
     * @param args Array of parameters passed to the application
     * via the command line.
     */
    public static void main (String[] args) {
                Database                server =3D null;
        String        username=3D"_SYSTEM";
        String        password=3D"sys";
        String        url =3D null;
        CacheQuery    cq =3D null;
        java.sql.ResultSet      rs =3D null;
        String          sql;
        String                  query =3D "";

        boolean isQuick =3D false;
        for (int i =3D 0; i < args.length; i++)
            if (args[i].equals("-quick"))
                isQuick =3D true;
            else if (args[i].equals("-url"))
                url =3D args[++i];
            else if (args[i].startsWith("jdbc:Cache:"))
                url =3D args[i];
            else if (args[i].equals("-query"))
                query =3D args[++i];

        if (url =3D=3D null)
            url =3D DEFAULT_URL;
   =20

        System.out.println( "Connecting to: " + url );
       =20
        /* Connect the ObjectServer to the url */
        try {
            if (isQuick)
                server =3D CacheDatabase.getLightDatabase (url, =
username, password);
            else
                server =3D CacheDatabase.getDatabase (url, username, =
password);


            /* Create the SQL statement */
            sql =3D "SELECT ID, Name, DOB, SSN FROM Sample.Person WHERE =
Name %STARTSWITH ?";
            System.out.println( "SQL: " + sql );
           =20
            /* Create a ResultSet */
            System.out.println( "Creating a ResultSet with Dynamic SQL" =
);

                        /* Create a CacheQuery */
                        cq =3D new CacheQuery( server, sql );
           =20
                        /* Execute the query and loop across the returned rows */
                        rs =3D cq.execute(query);
                        while (rs.next()) {
                                /* Dump the columns in each row */
                                String s =3D "";
                                for (int i =3D 1; i <=3D 
rs.getMetaData().getColumnCount(); i++) {
                                    if (s.length() > 0) {
                                        s +=3D ": ";
                                    }

                                    s +=3D rs.getString( i );
                                }

                                System.out.println( s );
                        }

                        /* Close the ResultSet object */
                        System.out.println("Closing ResultSet");
                        rs.close();

            /* Close the object factory */
            System.out.println( "Closing ObjectFactory" );

                server.close();
        } catch (CacheException ex) {
            System.out.println( "Caught exception: " + =
ex.getClass().getName() +=20
                                ": " + ex.getMessage() );
            ex.printFullTrace(System.out);
        } catch (SQLException ex) {
            for (SQLException x =3D ex; x !=3D null; =
x=3Dx.getNextException()){
                System.out.println("Caught SQL Exception. [Message: <" + =

                                   x.getMessage() +
                                   "> Error code: <" + x.getErrorCode() =
+
                                   "> SQL state: <" + x.getSQLState() +=20
                                   ">]");
                ex.printStackTrace();
            }
        } catch (Exception ex) {
            System.out.println( "Caught exception: " + =
ex.getClass().getName() +=20
                                ": " + ex.getMessage() );
            ex.printStackTrace();
        }
    }
}

/*
 * End-of-file
 *
 */


------=_NextPart_000_000C_01C477CA.1AF41740--


Reply via email to