------=_NextPart_000_001A_01C477AA.0E794230
Content-Type: text/plain;
        charset="iso-2022-jp"
Content-Transfer-Encoding: 7bit


"Warlin Garcia" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> What error are you getting?
>
> Can you post the code you're using?
>
> Warlin Garcia
> "compass" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > hi:
> >    Now I can  execute the sql like "select name from  library.user"  in
> > cache java binding.
> >   but I don't know how to execute the sql like "delete   from
> library.user
> > where user='Sam'"  in cache java binding.
>
>

------=_NextPart_000_001A_01C477AA.0E794230
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 ?";
          sql =3D "delete  FROM Sample.Person ";

            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);
                =09

                        /* 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_001A_01C477AA.0E794230--


Reply via email to