I was hoping someone could help me out.

I am working on a EJB, mostly for my own learning ability, so as I can build
on it later.

It should take the argument passed it by the client, execute it, and return
the results

What it does it take the argument, output the message I have for telling me
it is trying to register the driver, then not do anything else (ie: run the
query or display any of the other debugging messages I have, or display any
SQLExceptions)

I know the settings for the DB are correct, as I have a stand-alone java
class that works great.

I belive I am restricted from using Entity EJBs because the way the database
is set up (there is no unique Primary Key [there are 3 feilds that compose
the Primary Key, this is due to that the data is ported from a VMS flat-file
DB])

Examples are v.helpful since I am just starting to tackle EJBs.

---------- Start Code ---------------
import java.rmi.RemoteException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
import java.sql.*;
import oracle.jdbc.driver.*;

public class OracleQueryEJB implements SessionBean {

        // Common Variables.
        public String QueryResults = "\n";

        // Function: Perform Query - this loads the drivers and performs the
query
   public String PerformQuery(String QueryToDo) {
        QueryResults = "\n";

    try {

    QueryResults = QueryResults + "Registering Driver.\n";
        DriverManager.registerDriver (new
oracle.jdbc.driver.OracleDriver());

    QueryResults = QueryResults + "Setting up Connection.\n";
    Connection conn = DriverManager.getConnection
("jdbc:oracle:thin:@{machinename}:{port}:{databasenamehere}","{username}","{
password}");

    QueryResults = QueryResults + "Creating Statement.\n";
    Statement stmt = conn.createStatement ();

    QueryResults = QueryResults + "Executing Query.\n";
        ResultSet rset = stmt.executeQuery (QueryToDo);


        // Setup the results
    while (rset.next ()) {
       QueryResults = QueryResults + rset.getString (1);
          }  // END While
       QueryResults = QueryResults + "Query Should have completed.\n";

        }

        catch ( SQLException ex) {
       QueryResults = QueryResults + "Error On Query:\n";
                while (ex != null) {
                 QueryResults = QueryResults + "Message: " + ex.getMessage
() + "\n";
                 ex = ex.getNextException();
                } // end while
        }
        // end catch


        finally {


                return "Query: " + QueryToDo + QueryResults;


        }
        // end finally

        }
        // end FUNCTION PerformQuery

   public OracleQueryEJB() {}
   public void ejbCreate() {}
   public void ejbRemove() {}
   public void ejbActivate() {}
   public void ejbPassivate() {}
   public void setSessionContext(SessionContext sc) {}

} // OracleQueryEJB

------------ END CODE ----------------------

Kenneth Reising
 Systems Programmer II -
   Web Applications Developer
Gainesville Regional Utilities

Phone: 352-334-3400 x 1153
Email:  [EMAIL PROTECTED]
Web: http://www.gru.com

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to