Need help w corba/jdbc class

hi
i'm trying to get this class to work right, i don't think i'm coding it the right way, especially the getAllAccounts() and selectAccounts() methods. this code compiles cleanly, but i get runtime exceptions when i try to run my app. my runtime exceptions look like
############################ StackTrace ############################
java.lang.NullPointerException
at com.kafein.accountServices.AccountServiceImpl.getAllAccounts(AccountS
erviceImpl.java:218)
at com.kafein.idl.accountServices.AccountServicePOA._invoke(AccountServi
cePOA.java:74)
at org.jacorb.poa.RequestProcessor.invokeOperation(RequestProcessor.java
:247)
at org.jacorb.poa.RequestProcessor.process(RequestProcessor.java:477)
at org.jacorb.poa.RequestProcessor.run(RequestProcessor.java:604)
and
Creating 100 Accounts
org.omg.CORBA.UNKNOWN: This exception was reported by the server, it is only re-
thrown here. vmcid: 0x0 minor code: 0 completed: No
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Sou
rce)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.jacorb.orb.SystemExceptionHelper.read(SystemExceptionHelper.java:
157)
at org.jacorb.orb.connection.ReplyInputStream.checkExceptions(ReplyInput
Stream.java:117)
at org.jacorb.orb.Delegate.invoke(Delegate.java:942)
at org.omg.CORBA.portable.ObjectImpl._invoke(Unknown Source)
at com.kafein.idl.accountServices._AccountServiceStub.getAllAccounts(_Ac
countServiceStub.java:134)
at com.kafein.client.AccountClient.main(AccountClient.java:111)
org.omg.CORBA.UNKNOWN: This exception was reported by the server, it is only re-
thrown here. vmcid: 0x0 minor code: 0 completed: No
ORB shutting down...
code for this class is below...
// AccountServiceImpl.java: The AccountService Implementation
package com.kafein.accountServices;
import java.util.Hashtable;
import java.util.Calendar;
import java.util.GregorianCalendar;
import junit.framework.TestCase;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.omg.PortableServer.*;
import com.kafein.idl.accountServices.AccountServicePOA;
import com.kafein.idl.accountServices.AccountEntryStruct;
import com.kafein.idl.accountServices.AccountStruct;
import com.kafein.idl.utilities.DateTimeStruct;
import com.kafein.idl.exceptions.NotFoundException;
import com.kafein.idl.exceptions.DataValidationException;
import com.kafein.idl.errorCodes.DataValidationErrorCodes;
import com.kafein.utils.ServiceHandler;
import com.kafein.utils.Log;
import java.net.URL;
import java.sql.*;
import java.util.*;
* AccountServiceImpl is an implementation of the
* idl.accountServices.AccountService interface.
public class AccountServiceImpl extends AccountServicePOA {
  POA poa;
  private Hashtable accounts = new Hashtable(); // collection of Accounts
  private static int nextAccountID = 1; // global account ID
  Connection connection;
  Vector connections;
  Statement statement;
  PreparedStatement preparedStatement;
   * Construct an instance.
  public AccountServiceImpl(POA aPOA, String driver, String url, String user, String password) {
    super();
    poa = aPOA;
    driver = driver;
    url = url;
    user = user;
    password = password;
    connections = new Vector();
    // Connect to Database
    try {
        connect(driver,url,user,password);
    catch(Exception e) {
           e.printStackTrace();       
    // Simple Database Select
    try {
        testSimpleSelect();
    catch(Exception e) {
           e.printStackTrace();       
    // Database Select
    try {
        testSelect();
    catch(Exception e) {
           e.printStackTrace();       
   * Overloaded constructor for unit tests.
  protected AccountServiceImpl() {
    poa = null;
   * createAccount is used by administrator to add a new Account
   * in the system.
   * @param newAccount AccountEntryStruct containing data for new account
   * @return int the new unique Account ID
   * @exception com.kafein.idl.exceptions.DataValidationException
  public int createAccount(AccountEntryStruct newAccount) throws
    DataValidationException {
    validateData (newAccount); // throws DataValidationException;
    int accountID = getNextID();     
    // Create new Account.
    Account anAccount = new Account(accountID,
                        newAccount.userName,
                        newAccount.userEmail,
                        newAccount.creditCardType,
                        newAccount.creditCardNumber,
                        newAccount.creditCardExpirationDate.year,
                        newAccount.creditCardExpirationDate.month,
                        newAccount.userPassword,
                        newAccount.initialBalance);
// Insert here / call method insertAccount() pass it in an account object
// or call manager object - accountmanager.put()
    // Insert Account into Database
    try {
        insertAccount(anAccount);
    catch(Exception e) {
           e.printStackTrace();       
    accounts.put(accountID,anAccount);
    return accountID;
   * isAccountValid is used to validate a user logon.
   * @param accountID AccountID
   * @param userPassword String
   * @return boolean true to indicate an existing Account
  public boolean isValidAccount (int accountID, String userPassword) {
    // Get account with key equal to accountID.
    AccountStruct anAccount;
    try {
      anAccount = (AccountStruct) getAccount (accountID);
    catch (NotFoundException e) {
      return false;
    // Verify password.
    return (anAccount.userPassword.equals(userPassword) ? true : false);
   * getAccount is used to retrieve an existing Account in the system
   * @param int AccountID
   * @return AccountStruct containing data for the existing Account
   * @exception com.kafein.idl.exceptions.NotFoundException
  public AccountStruct getAccount(int accountID)throws
    NotFoundException {
    // Verify that accountID is within an appropriate interval.
    if (accountID < 1 || accountID > accounts.size()) {
      throw new NotFoundException(DataValidationErrorCodes.INVALID_ACCOUNT_ID,
                      "Account ID not found");
    // Get Account and convert to AccountStruct (which is returned).
    Account anAccount = (Account) accounts.get(accountID);
    return anAccount.getAccountStruct();
   * getAllAccounts is used to retrieve all existing Accounts in the system
   * @return AccountStruct[] containing all existing Accounts.
   * @fyi returns an empty sequence if no Accounts exist
  // GetAllAcounts method v. 2 - rather than enumerating through the vector
  // call a method that returns a collection of objs in that method where
  // you do select stmts
  public AccountStruct[] getAllAccounts() {
    // Allocate the array of AccountStructs.
    Vector results = new Vector();
    try {
            results = selectAccounts();
    catch(Exception e) {
           e.printStackTrace();       
    //Vector results = selectAccounts();
    int lastKey = results.size();
    //int lastKey = accounts.size();
    AccountStruct[] accountSequence = new AccountStruct[lastKey];
    if (lastKey==0) {
      return accountSequence;
    // Create AccountStructs from Accounts.
    for (int i = 1; i <= lastKey; i++) {
      Account anAccount = (Account) accounts.get(i);
      accountSequence[i-1] = anAccount.getAccountStruct();
    return accountSequence;
   * validateData is used to check new account data.
   * @param newAccount AccountEntryStruct containing data for new account
   * @exception com.kafein.idl.exceptions.DataValidationException
  protected void validateData(AccountEntryStruct newAccount) throws
    DataValidationException {
    // Check all of the member data in newAccount.
    if (newAccount.userName.equals("")) {
      throw new DataValidationException(
          DataValidationErrorCodes.INVALID_USER_NAME,
          "User Name must not be empty");
    if (newAccount.userEmail.equals("")) {
      throw new DataValidationException(
          DataValidationErrorCodes.INVALID_USER_EMAIL,
          "User Email must not be empty");
    if (newAccount.creditCardType.equals("")) {
      throw new DataValidationException(
          DataValidationErrorCodes.INVALID_CREDIT_CARD_TYPE,
          "Credit card type must not be empty");
    if (newAccount.creditCardNumber.equals("")) {
      throw new DataValidationException(
          DataValidationErrorCodes.INVALID_CREDIT_CARD_NUMBER,
          "Credit card number must not be empty");
    // Compare creditCardExpirationDate to current date
    // (we only consider year and month).
    GregorianCalendar now = new GregorianCalendar();
    DateTimeStruct proposed = newAccount.creditCardExpirationDate;
    if (proposed.year < now.get (Calendar.YEAR) ||
     (proposed.year == now.get (Calendar.YEAR) &&
      proposed.month < now.get (Calendar.MONTH) + 1)) {
      throw new DataValidationException(
          DataValidationErrorCodes.INVALID_CREDIT_CARD_EXPIRATION_DATE,
          "Credit card has expired");
    if (newAccount.userPassword.equals("")) {
      throw new DataValidationException(
          DataValidationErrorCodes.INVALID_USER_PASSWORD,
          "Password must not be empty");
    else if (!newAccount.userPassword.equals(newAccount.userPasswordVerification)) {
      throw new DataValidationException(
          DataValidationErrorCodes.INVALID_USER_PASSWORD,
          "Password verification failure");
    if (newAccount.initialBalance < 0.0F) {
      throw new DataValidationException(
          DataValidationErrorCodes.INVALID_BALANCE,
          "Account Balance cannot have a negative balance");
   * getNextID is used to generate a unique ID.
   * Needs a much better implementation that generates a globally unique ID!
   * @return int an Account ID
  protected synchronized int getNextID() {
    nextAccountID++;
    return nextAccountID - 1;
   * override _default_POA to return this servant's POA, not Root POA
  public POA _default_POA() {
    return poa;
   * jdbc related methods
  public void connect(String driver, String url, String user, String password)
                throws Exception {
        try {
            // Load JDBC driver
            Class.forName(driver);
            System.out.println("Connecting to " + url);
            connection = DriverManager.getConnection(url, user, password);
            connections.add(connection);
            connection.setAutoCommit(false);
        } catch(Exception e) {
            System.err.println("System Exception in connect");
            System.err.println(e);
            throw e;
  public void closeConnection() throws Exception {
        try {
            Enumeration myEnum = connections.elements();
            while ( myEnum.hasMoreElements() ) {
                System.out.println("Closing connection");
                ((Connection) myEnum.nextElement()).close();
        } catch (Exception e) {
            System.err.println("System Exception in closeConnection");
            System.err.println(e);
            throw e;
  private void testSimpleSelect() throws Exception {
        try {
            Statement statement = connection.createStatement();
            ResultSet rs = statement.executeQuery("Select 1 from ACCOUNT");
            if (rs != null && rs.next()) {
               int value = rs.getInt(1);
               System.out.println("Fetched value " + value);
            connection.commit();
            statement.close();
        } catch(Exception e) {
            System.err.println("System Exception in testSimpleSelect");
            System.err.println(e);
            throw e;
  private void testSelect() throws Exception {
        try {
            Statement statement = connection.createStatement();
            ResultSet rs = statement.executeQuery(
                "Select ACCT_ID, ACCT_USERNAME, ACCT_USEREMAIL, ACCT_CC_TYPE, ACCT_CC_NUMBER, ACCT_CC_EXPYR, ACCT_CC_EXPMO, ACCT_USERPASSWORD, ACCT_USERBALANCE from ACCOUNT LIMIT 1");
            System.out.println("Account ID   User Name     User Email     CC Type     CC Number     CC Expyr CC Expmo User Password     User Balance");
            while (rs != null && rs.next()) {
                int acct_id = rs.getInt(1);
                String acct_username = rs.getString(2);
                String acct_useremail = rs.getString(3);
                String acct_cc_type = rs.getString(4);
                String acct_cc_number = rs.getString(5);
                int acct_cc_expyr = rs.getInt(6);
                int acct_cc_expmo = rs.getInt(7);
                String acct_userpassword = rs.getString(8);
                float acct_userbalance = rs.getFloat(9);
                System.out.println(acct_id + "         " +
                                   acct_username + "   " +
                                   acct_useremail + "   " +
                                   acct_cc_type + "   " +
                                   acct_cc_number + "   " +
                                   acct_cc_expyr + "   " +
                                   acct_cc_expmo + "   " +
                                   acct_userpassword + "   " +
                                   acct_userbalance);
            connection.commit();
            statement.close();
        } catch(Exception e) {
            System.err.println("System Exception in testSelect");
            System.err.println(e);
            throw e;
  private void testLoadData() throws Exception {
        int numberOfAccounts = 5;
        String  acct_username    = "<--20 BYTE STRING-->";
        String  acct_useremail = "<--20 BYTE STRING-->";
     String  acct_cc_type = "TEST ";
        String  acct_cc_number = "<--20 BYTE STRING-->";
        int  acct_cc_expyr = 2000;
        int  acct_cc_expmo = 1;
        String  acct_userpassword = "<--20 BYTE STRING-->";
        float     acct_userbalance = 0.0F;
        int     acct_id = 0;
     try {
            System.out.println("Inserting data...");
            connection.setAutoCommit(false);
            // Calculate Start time
            System.out.println("Starting data insertion (" + numberOfAccounts +
                " rows) into ACCOUNT table..");
            long startTime = System.currentTimeMillis();
            preparedStatement = connection.prepareStatement(
                "INSERT INTO ACCOUNT (ACCT_ID, ACCT_USERNAME, ACCT_USEREMAIL, ACCT_CC_TYPE, ACCT_CC_NUMBER, " +
                "ACCT_CC_EXPYR, ACCT_CC_EXPMO, ACCT_USERPASSWORD, ACCT_USERBALANCE) VALUES ( ?, ?, ?, ?, ?, ? , ?, ?, ?)");
            // Insert accounts in ACCOUNT table
            for (int i = 1; i <= numberOfAccounts; i++) {
                acct_id  = i * 1000;
                preparedStatement.setInt(1, acct_id);
                preparedStatement.setString(2, acct_username);
                preparedStatement.setString(3, acct_useremail);
                preparedStatement.setString(4, acct_cc_type);
                preparedStatement.setString(5, acct_cc_number);
                preparedStatement.setInt(6, acct_cc_expyr);
                preparedStatement.setInt(7, acct_cc_expmo);
                preparedStatement.setString(8, acct_userpassword);
                preparedStatement.setFloat(9, acct_userbalance);
          preparedStatement.executeUpdate();
                connection.commit();
            System.out.println(numberOfAccounts + " accounts created.");
            preparedStatement.close();
            long stopTime = System.currentTimeMillis();
            System.out.println("Account table load complete.");
            System.out.println("Load time = " +
                               ((stopTime - startTime)/(1000f)) + " seconds");
            System.out.println("Data insertion complete");
        } catch(Exception e) {
            System.err.println("System Exception in loadData");
            System.err.println(e);
            throw e;
   * insertAccount is used to insert a new Account in the Database
   * @param int AccountID
   * @return AccountStruct containing data for the existing Account
  private void insertAccount(Account anAccount) throws Exception {
          AccountStruct anAccountStruct = anAccount.getAccountStruct();  
     int numberOfAccounts = 1;
     String  acct_username    = anAccountStruct.userName;
        String  acct_useremail = anAccountStruct.userEmail;
     String  acct_cc_type = anAccountStruct.creditCardType;
        String  acct_cc_number = anAccountStruct.creditCardNumber;
     int acct_cc_expyr = anAccountStruct.creditCardExpirationDate.year;
        int acct_cc_expmo = anAccountStruct.creditCardExpirationDate.month;
        String  acct_userpassword = anAccountStruct.userPassword;
        float     acct_userbalance = anAccountStruct.accountBalance;
        int     acct_id = anAccountStruct.accountID;
     try {
            System.out.println("Inserting data...");
            connection.setAutoCommit(false);
//instead of system.out just log
            // Calculate Start time
            System.out.println("Starting data insertion ( 1" +
                " row) into ACCOUNT table..");
            long startTime = System.currentTimeMillis();
            preparedStatement = connection.prepareStatement(
                "INSERT INTO ACCOUNT (ACCT_ID, ACCT_USERNAME, ACCT_USEREMAIL, ACCT_CC_TYPE, ACCT_CC_NUMBER, " +
                "ACCT_CC_EXPYR, ACCT_CC_EXPMO, ACCT_USERPASSWORD, ACCT_USERBALANCE) VALUES ( ?, ?, ?, ?, ?, ? , ?, ?, ?)");
                acct_id  = 1000;
                preparedStatement.setInt(1, acct_id);
                preparedStatement.setString(2, acct_username);
                preparedStatement.setString(3, acct_useremail);
                preparedStatement.setString(4, acct_cc_type);
                preparedStatement.setString(5, acct_cc_number);
                preparedStatement.setInt(6, acct_cc_expyr);
                preparedStatement.setInt(7, acct_cc_expmo);
                preparedStatement.setString(8, acct_userpassword);
                preparedStatement.setFloat(9, acct_userbalance);
          preparedStatement.executeUpdate();
                connection.commit();
            System.out.println("1 account created.");
            preparedStatement.close();
            long stopTime = System.currentTimeMillis();
            System.out.println("Account table load complete.");
            System.out.println("Load time = " +
                               ((stopTime - startTime)/(1000f)) + " seconds");
            System.out.println("Data insertion complete");
        } catch(Exception e) {
            System.err.println("System Exception in loadData");
            System.err.println(e);
            throw e;
  private Vector selectAccounts() throws Exception {
        try {
            // Create Vector to hold individual Account values
         Vector mainvector = new Vector();
         Vector values = new Vector();
         Statement statement = connection.createStatement();
            ResultSet rs = statement.executeQuery(
                "Select ACCT_ID, ACCT_USERNAME, ACCT_USEREMAIL, ACCT_CC_TYPE, ACCT_CC_NUMBER, ACCT_CC_EXPYR, ACCT_CC_EXPMO, ACCT_USERPASSWORD, ACCT_USERBALANCE from ACCOUNT");
            System.out.println("Account ID   User Name     User Email     CC Type     CC Number     CC Expyr CC Expmo User Password     User Balance");
         // Iterate through result set
         while (rs != null && rs.next()) {
          // Make sure values is empty
          values.clear();
          int acct_id = rs.getInt(1);
                String acct_username = rs.getString(2);
                String acct_useremail = rs.getString(3);
                String acct_cc_type = rs.getString(4);
                String acct_cc_number = rs.getString(5);
                int acct_cc_expyr = rs.getInt(6);
                int acct_cc_expmo = rs.getInt(7);
                String acct_userpassword = rs.getString(8);
                float acct_userbalance = rs.getFloat(9);
          // Populate Vector values
          values.addElement(rs.getObject(1));
          values.addElement(rs.getObject(2));
          values.addElement(rs.getObject(3));
          values.addElement(rs.getObject(4));
          values.addElement(rs.getObject(5));
          values.addElement(rs.getObject(6));
          values.addElement(rs.getObject(7));
          values.addElement(rs.getObject(8));
          values.addElement(rs.getObject(9));
          mainvector.addElement(values);
                System.out.println(acct_id + "         " +
                                   acct_username + "   " +
                                   acct_useremail + "   " +
                                   acct_cc_type + "   " +
                                   acct_cc_number + "   " +
                                   acct_cc_expyr + "   " +
                                   acct_cc_expmo + "   " +
                                   acct_userpassword + "   " +
                                   acct_userbalance);
            connection.commit();
            statement.close();
         return mainvector;
        } catch(Exception e) {
            System.err.println("System Exception in selectAccounts");
            System.err.println(e);
            throw e;
    }

line 217 and 218 is
Account anAccount = (Account) accounts.get(i);
accountSequence[i-1] = anAccount.getAccountStruct();
i realized that
Account anAccount = (Account) accounts.get(i);
was a typo. what it should have been was
Account anAccount = (Account) results.get(i);
so my getAllAccounts() method now looks like
   * getAllAccounts is used to retrieve all existing Accounts in the system
   * @return AccountStruct[] containing all existing Accounts.
   * @fyi returns an empty sequence if no Accounts exist
  // GetAllAcounts method v. 2 - rather than enumerating through the vector
  // call a method that returns a collection of objs in that method where
  // you do select stmts
  public AccountStruct[] getAllAccounts() {
    // Allocate the array of AccountStructs.
    Vector results = new Vector();
    try {
            results = selectAccounts();
    catch(Exception e) {
           e.printStackTrace();       
    //Vector results = selectAccounts();
    int lastKey = results.size();
    //int lastKey = accounts.size();
    AccountStruct[] accountSequence = new AccountStruct[lastKey];
    if (lastKey==0) {
      return accountSequence;
    // Create AccountStructs from Accounts.
    for (int i = 1; i <= lastKey; i++) {
      Account anAccount = (Account) results.get(i);
      accountSequence[i-1] = anAccount.however, i still get the same runtime errors.
is my selectAccounts() method returning a null?

Similar Messages

  • Hi I need help on URL Connection Class

    Hi
    I have read the documentation but cant get it . I have to Use the getContent(); method so can any one make a program for me in which all of the methods of this class have been used?
    I Also Need help on Content Handler Class Please give me one example on it but separate from the above one
    Thanx alot

    Hi
    Man Some Times We need help and as of google, Google is My Best Friend. and as of forums search i know that but some time we have less time and much to work. The Time Doesnt wait us. we have to save our time. thanx for ur help and ur comments i like it.

  • Need help with assignment for class. its for my high school project :(

    i really need help, my problem is that with my code i cannot get the "previous", "done" and "next" buttons to work.they cannot seem to find the items from each other. so could someone look at those buttons in the code and tell me how to fix please? the code is as follows:
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class GradeCalculator extends JFrame {
         private JTextField gradeA = new JTextField(3);
         private JTextField gradeB = new JTextField(3);
         private JTextField gradeC = new JTextField(3);
         private JTextField gradeD = new JTextField(3);
         private JTextField gradeE = new JTextField(3);
         private JTextField studentsName = new JTextField(15);
         private JTextField assignmentOne = new JTextField(5);
         private JTextField assignmentTwo = new JTextField(5);
         private JTextField assignmentThree = new JTextField(5);
         private JTextField examOne = new JTextField(5);
         private JTextField examTwo = new JTextField(5);
         private JTextArea textOutput;
         private JPanel buttonJPanel;
         public GradeCalculator(){
              JMenu fileMenu = new JMenu("File");
              JMenuItem aboutItem = new JMenuItem( "About" );
    fileMenu.add( aboutItem );
    aboutItem.addActionListener(
    new ActionListener()
    public void actionPerformed( ActionEvent event )
    JOptionPane.showMessageDialog( GradeCalculator.this,
    "Grade Calculator Version 1.00. \nMade by Carlson Smith.\nSchool: Pre-University\nSubject: Cape Computer Science.",
    "About", JOptionPane.PLAIN_MESSAGE );
              JMenuItem exitItem = new JMenuItem( "Exit" );
    fileMenu.add( exitItem );
    exitItem.addActionListener(
    new ActionListener()
    public void actionPerformed( ActionEvent event )
    System.exit( 0 );
              JMenuBar bar = new JMenuBar();
              setJMenuBar(bar);
              bar.add(fileMenu);     
              JTabbedPane tabbedPane = new JTabbedPane();
              buttonJPanel = new JPanel();
              buttonJPanel.setLayout(new GridLayout(1,2));
              JButton ok = new JButton("OK");
              ok.addActionListener(new OkBtnListener());
              JButton edit = new JButton("EDIT");
              edit.addActionListener(new EditBtnListener());
              /**JButton previous = new JButton("PREVIOUS");
              previous.addActionListener(new PreviousBtnListener());
              JButton done = new JButton("DONE");
              done.addActionListener(new DoneBtnListener());
              JButton next = new JButton("NEXT");
              next.addActionListener(new NextBtnListener());
              JPanel contentPane = new JPanel();
              contentPane.setLayout(new FlowLayout());
              contentPane.add(new JLabel("Grade A")/**,BorderLayout.NORTH*/);
              contentPane.add(gradeA/**,BorderLayout.NORTH*/);
              contentPane.add(new JLabel("Grade B")/**,BorderLayout.WEST*/);
              contentPane.add(gradeB/**,BorderLayout.WEST*/);
              contentPane.add(new JLabel("Grade C")/**,BorderLayout.WEST*/);
              contentPane.add(gradeC/**,BorderLayout.WEST*/);
              contentPane.add(new JLabel("Grade D")/**,BorderLayout.WEST*/);
              contentPane.add(gradeD/**,BorderLayout.WEST*/);
              contentPane.add(new JLabel("Grade E")/**,BorderLayout.WEST*/);
              contentPane.add(gradeE/**,BorderLayout.WEST*/);
              tabbedPane.addTab("Grade Entry Tab", null, contentPane, "Grade Tab");
              //contentPane.add(ok,BorderLayout.WEST);
              //contentPane.add(edit,BorderLayout.WEST);
              buttonJPanel.add(ok);
              buttonJPanel.add(edit);
              contentPane.add(buttonJPanel, BorderLayout.WEST);
              JPanel content = new JPanel();
              content.setLayout(new FlowLayout());
              content.add(new JLabel("Student's Name")/**,BorderLayout.EAST*/);
              content.add(studentsName/**,BorderLayout.EAST*/);
              content.add(new JLabel("Assignment 1 score:")/**,BorderLayout.EAST*/);
              content.add(assignmentOne/**,BorderLayout.EAST*/);
              content.add(new JLabel("Assignment 2 score:")/**,BorderLayout.EAST*/);
              content.add(assignmentTwo/**,BorderLayout.EAST*/);
              content.add(new JLabel("Assignment 3 score:")/**,BorderLayout.EAST*/);
              content.add(assignmentThree/**,BorderLayout.EAST*/);
              content.add(new JLabel("Exam 1 score:")/**,BorderLayout.EAST*/);
              content.add(examOne/**,BorderLayout.EAST*/);
              content.add(new JLabel("Exam 2 score:")/**,BorderLayout.EAST*/);
              content.add(examTwo/**,BorderLayout.EAST*/);
              //content.add(previous,BorderLayout.EAST);
              //content.add(done,BorderLayout.EAST);
              //content.add(next,BorderLayout.EAST);
              Box box = Box.createVerticalBox();
              String output = "test";
              String outputTwo = output;
              textOutput = new JTextArea(outputTwo,10,30);
              box.add(new JScrollPane(textOutput));
              textOutput.setEditable(false);
              content.add(box,BorderLayout.SOUTH);
              tabbedPane.addTab("Calculator Tab", null, content, "Calculation & Output Tab");
              setContentPane(tabbedPane);
              pack();
              setTitle("Grade Calculator");
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              setLocationRelativeTo(null);
              class OkBtnListener implements ActionListener{
                   public void actionPerformed(ActionEvent e){
                        String gradeAA = gradeA.getText();
                        double gradA = Double.parseDouble(gradeAA);
                        gradeA.setText(" "+gradA);
                        String gradeBB = gradeB.getText();
                        double gradB = Double.parseDouble(gradeBB);
                        gradeB.setText(" "+gradB);
                        String gradeCC = gradeC.getText();
                        double gradC = Double.parseDouble(gradeCC);
                        gradeC.setText(" "+gradC);
                        String gradeDD = gradeD.getText();
                        double gradD = Double.parseDouble(gradeDD);
                        gradeD.setText(" "+gradD);
                        String gradeEE = gradeE.getText();
                        double gradE = Double.parseDouble(gradeEE);
                        gradeE.setText(" "+gradE);
                        gradeA.setEditable(false);
                        gradeB.setEditable(false);
                        gradeC.setEditable(false);
                        gradeD.setEditable(false);
                        gradeE.setEditable(false);
              class EditBtnListener implements ActionListener{
                   public void actionPerformed(ActionEvent e){
                        gradeA.setEditable(true);
                        gradeB.setEditable(true);
                        gradeC.setEditable(true);
                        gradeD.setEditable(true);
                        gradeE.setEditable(true);
              /**class PreviousBtnListener implements ActionListener{
                   public void actionPerformed(ActionEvent e){
                        if (i <= 0){
                             i = 0;
                        }else if(i > 0){
                             i = i-1;
              class DoneBtnListener implements ActionListener{
                   public void actionPerformed(ActionEvent e){
                        output = "Results \n";
                        output+= studentName[i]+" Assignment Average = "+averageO[i]+" Exam Average = "+averageT[i]+" Overall average = ";
                        output+= tAverage[i]+" Letter Grade = "+letterGrade;
              class NextBtnListener implements ActionListener{
                   public void actionPerformed(ActionEvent e){
                        String [] studentName = new String [40];
                        double [] assignOne = new double [40];
                        double [] assignTwo = new double [40];
                        double [] assignThree = new double [40];
                        double [] gradeOne = new double [40];
                        double [] gradeTwo = new double [40];
                        double [] averageO = new double [40];
                        double [] averageT = new double [40];
                        double [] tAverage = new double [40];
                        char [] letterGrade = new char [40];
                        double max = 0;
                        double min = 100;
                        int i = 0;
                        while(i < studentName.length){
                             studentName[i] = studentsName.getText();
                             studentsName.setText(studentName[i]);
                             String aOne = assignmentOne.getText();
                             assignOne[i] = Double.parseDouble(aOne);
                             assignmentOne.setText(assignOne[i]);
                             String aTwo = assignmentTwo.getText();
                             assignTwo[i] = Double.parseDouble(aTwo);
                             assignmentTwo.setText(assignTwo[i]);
                             String aThree = assignmentThree.getText();
                             assignThree[i] = Double.parseDouble(aThree);
                             assignmentThree.setText(assignThree[i]);
                             String gOne = examOne.getText();
                             gradeOne[i] = Double.parseDouble(gOne);
                             examOne.setText(gradeOne[i]);
                             String gTwo = examTwo.getText();
                             gradeTwo = Double.parseDouble(gTwo);
                             examTwo.setText(gradeTwo[i]);
                             averageO[i] = (assignOne[i]+assignTwo[i]+assignThree[i])/3;
                             averageT[i] = (gradeOne[i]+gradeTwo[i])/2;
                             tAverage[i] = (averageO[i]+averageT[i])/2;
                             if (tAverage[i] >= gradeA){
                                  letterGrade[i] = 'A';
                             }else if(tAverage[i] >= gradeB){
                                  letterGrade[i] = 'B';
                             }else if(tAverage[i] >= gradeC){
                                  letterGrade[i] = 'C';
                             }else if(tAverage[i] >= gradeD){
                                  letterGrade[i] = 'D';
                             }else if(tAverage[i] <= gradeE){
                                  letterGrade[i] = 'E';
              public static void main(String[]args){
                   GradeCalculator calWindow = new GradeCalculator();
                   calWindow.setVisible(true);

    i have to apologize to jittei for the misunderstand i do not know which defination of terms is for which line of code but i know what they do, to solve the problem i have actually made another class in the workspace file called students and now all the bottons work, all i have to do now is properly arrange and put in some additional lines of code and it will be completed. teacher gave me the idea of putting in a new class to help in calling codes from other subclasses in the main program. ah well guess non of you could think of that thanks for the help-ish and hope yall will atleast try to be nice to new people that come in the room. the new coding is:
    of course all the commented out lines are not being used in the program anymore but just there till i have the program working with everything in it runs and performs the actions required now though ^_^
    *Group CAPE Computer Science 2007/8
    *GradeCalculator.java
    *@author Carlson Smith
    *@version 3.01          07/02/2008
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class GradeCalculator extends JFrame {
         private JTextField gradeA = new JTextField(3);
         private JTextField gradeB = new JTextField(3);
         private JTextField gradeC = new JTextField(3);
         private JTextField gradeD = new JTextField(3);
         private JTextField gradeE = new JTextField(3);
         private JTextField studentsName = new JTextField(15);
         private JTextField assignmentOne = new JTextField(5);
         private JTextField assignmentTwo = new JTextField(5);
         private JTextField assignmentThree = new JTextField(5);
         private JTextField examOne = new JTextField(5);
         private JTextField examTwo = new JTextField(5);
         private JTextArea  textOutput;
         private JPanel buttonJPanel;
         private JPanel buttonJPanelTwo;
         private Student [] students = new Student[40];
         private int current = 0;
         private String output;
         public GradeCalculator(){
              JMenu fileMenu = new JMenu("File");
              JMenuItem aboutItem = new JMenuItem( "About" );
              for (int i=0;i<40;i++){
                   students[i] = new Student("");
            fileMenu.add( aboutItem );
            aboutItem.addActionListener(
               new ActionListener()
                  public void actionPerformed( ActionEvent event )
                     JOptionPane.showMessageDialog( GradeCalculator.this,
                        "Grade Calculator Version 1.00. \nMade by Carlson Smith.\nSchool: Pre-University\nSubject: Cape Computer Science.",
                        "About", JOptionPane.PLAIN_MESSAGE );
              JMenuItem exitItem = new JMenuItem( "Exit" ); 
            fileMenu.add( exitItem );
            exitItem.addActionListener(
               new ActionListener()
                  public void actionPerformed( ActionEvent event )
                     System.exit( 0 );
              JMenuBar bar = new JMenuBar();
              setJMenuBar(bar);
              bar.add(fileMenu);     
              JTabbedPane tabbedPane = new JTabbedPane();
              buttonJPanel = new JPanel();
              buttonJPanel.setLayout(new GridLayout(1,2));
              JButton ok = new JButton("OK");
              ok.addActionListener(new OkBtnListener());
              JButton edit = new JButton("EDIT");
              edit.addActionListener(new EditBtnListener());
              buttonJPanelTwo = new JPanel();
              buttonJPanelTwo.setLayout(new GridLayout(1,3));
              JButton previous = new JButton("PREVIOUS");
              previous.addActionListener(new PreviousBtnListener());
              JButton done = new JButton("DONE");
              done.addActionListener(new DoneBtnListener());
              JButton next = new JButton("NEXT");
              next.addActionListener(new NextBtnListener());
              JPanel contentPane = new JPanel();
              contentPane.setLayout(new FlowLayout());
              contentPane.add(new JLabel("Grade A")/**,BorderLayout.NORTH*/);
              contentPane.add(gradeA/**,BorderLayout.NORTH*/);
              contentPane.add(new JLabel("Grade B")/**,BorderLayout.WEST*/);
              contentPane.add(gradeB/**,BorderLayout.WEST*/);
              contentPane.add(new JLabel("Grade C")/**,BorderLayout.WEST*/);
              contentPane.add(gradeC/**,BorderLayout.WEST*/);
              contentPane.add(new JLabel("Grade D")/**,BorderLayout.WEST*/);
              contentPane.add(gradeD/**,BorderLayout.WEST*/);
              contentPane.add(new JLabel("Grade E")/**,BorderLayout.WEST*/);
              contentPane.add(gradeE/**,BorderLayout.WEST*/);
              tabbedPane.addTab("Grade Entry Tab", null, contentPane, "Grade Tab");
              //contentPane.add(ok,BorderLayout.WEST);
              //contentPane.add(edit,BorderLayout.WEST);
              buttonJPanel.add(ok);
              buttonJPanel.add(edit);
              contentPane.add(buttonJPanel, BorderLayout.WEST);
              JPanel content = new JPanel();
              content.setLayout(new FlowLayout());
              content.add(new JLabel("Student's Name")/**,BorderLayout.EAST*/);
              content.add(studentsName/**,BorderLayout.EAST*/);
              content.add(new JLabel("Assignment 1 score:")/**,BorderLayout.EAST*/);
              content.add(assignmentOne/**,BorderLayout.EAST*/);
              content.add(new JLabel("Assignment 2 score:")/**,BorderLayout.EAST*/);
              content.add(assignmentTwo/**,BorderLayout.EAST*/);
              content.add(new JLabel("Assignment 3 score:")/**,BorderLayout.EAST*/);
              content.add(assignmentThree/**,BorderLayout.EAST*/);
              content.add(new JLabel("Exam 1 score:")/**,BorderLayout.EAST*/);
              content.add(examOne/**,BorderLayout.EAST*/);
              content.add(new JLabel("Exam 2 score:")/**,BorderLayout.EAST*/);
              content.add(examTwo/**,BorderLayout.EAST*/);
              //content.add(previous,BorderLayout.EAST);
              //content.add(done,BorderLayout.EAST);
              //content.add(next,BorderLayout.EAST);
              buttonJPanelTwo.add(previous);
              buttonJPanelTwo.add(done);
              buttonJPanelTwo.add(next);
              content.add(buttonJPanelTwo, BorderLayout.EAST);
              Box box = Box.createVerticalBox();
              //String outputTwo = output;
              //textOutput.setText(output);
              textOutput = new JTextArea(output,10,30);
              box.add(new JScrollPane(textOutput));
              //textOutput.setEditable(true);
              content.add(box,BorderLayout.SOUTH);
              tabbedPane.addTab("Calculator Tab", null, content, "Calculation & Output Tab");
              setContentPane(tabbedPane);
              pack();
              setTitle("Grade Calculator");
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              setLocationRelativeTo(null);
              class OkBtnListener implements ActionListener{
                   public void actionPerformed(ActionEvent e){
                        String gradeAA = gradeA.getText();
                        double gradA = Double.parseDouble(gradeAA);
                        gradeA.setText(" "+gradA);
                        String gradeBB = gradeB.getText();
                        double gradB = Double.parseDouble(gradeBB);
                        gradeB.setText(" "+gradB);
                        String gradeCC = gradeC.getText();
                        double gradC = Double.parseDouble(gradeCC);
                        gradeC.setText(" "+gradC);
                        String gradeDD = gradeD.getText();
                        double gradD = Double.parseDouble(gradeDD);
                        gradeD.setText(" "+gradD);
                        String gradeEE = gradeE.getText();
                        double gradE = Double.parseDouble(gradeEE);
                        gradeE.setText(" "+gradE);
                        gradeA.setEditable(false);
                        gradeB.setEditable(false);
                        gradeC.setEditable(false);
                        gradeD.setEditable(false);
                        gradeE.setEditable(false);
              class EditBtnListener implements ActionListener{
                   public void actionPerformed(ActionEvent e){
                        gradeA.setEditable(true);
                        gradeB.setEditable(true);
                        gradeC.setEditable(true);
                        gradeD.setEditable(true);
                        gradeE.setEditable(true);
              class PreviousBtnListener implements ActionListener{
                   public void actionPerformed(ActionEvent e){
                        Student currentStudent = students[current];
                        currentStudent.setStudentName(studentsName.getText());          
                        currentStudent.setAssignOne(Double.parseDouble(assignmentOne.getText()));
                        currentStudent.setAssignTwo(Double.parseDouble(assignmentTwo.getText()));
                        currentStudent.setAssignThree(Double.parseDouble(assignmentThree.getText()));
                        currentStudent.setExamOneGrade(Double.parseDouble(examOne.getText()));
                        currentStudent.setExamTwoGrade(Double.parseDouble(examTwo.getText()));
                        currentStudent = students[current];
                        if (current <= 0){
                             current = 0;
                        }else if(current > 0){
                             current = current-1;
                        refresh();               
                        System.out.println(current);
              class DoneBtnListener implements ActionListener{
                   public void actionPerformed(ActionEvent e){
                        Student currentStudent = students[current];
                        //output = "Result \n";
                        output = currentStudent.getStudentName()+". Assignment Average = "+currentStudent.getAverage()+". Exam Average = "+currentStudent.getExamAverage()+". Overall average = ";
                        output+= currentStudent.getTotalAverage()/**+" Letter Grade = "+letterGrade[current]*/;
                        textOutput.setText(output);
                        System.out.println(output);
                        currentStudent = students[current];
              class NextBtnListener implements ActionListener{
                   public void actionPerformed(ActionEvent e){
    //                    String [] studentName = new String [40];
    //                    double [] assignOne = new double [40];
    //                    double [] assignTwo = new double [40];
    //                    double [] assignThree = new double [40];
    //                    double [] gradeOne = new double [40];
    //                    double [] gradeTwo = new double [40];
    //                    double [] averageO = new double [40];
    //                    double [] averageT = new double [40];
    //                    double [] tAverage = new double [40];
    //                    char [] letterGrade = new char [40];
                        //double max = 0;
                        //double min = 100;
                        Student currentStudent = students[current];
                        currentStudent.setStudentName(studentsName.getText());
                        currentStudent.setAssignOne(Double.parseDouble(assignmentOne.getText()));
                        currentStudent.setAssignTwo(Double.parseDouble(assignmentTwo.getText()));
                        currentStudent.setAssignThree(Double.parseDouble(assignmentThree.getText()));
                        currentStudent.setExamOneGrade(Double.parseDouble(examOne.getText()));
                        currentStudent.setExamTwoGrade(Double.parseDouble(examTwo.getText()));
    //                    currentStudent = students[current];
                        current++;
                        refresh();
    /**                    while(i < studentName.length){
                             String aOne = assignmentOne.getText();
                             assignOne[i] = Double.parseDouble(aOne);
                             assignmentOne.setText(" "+assignOne);
                             String aTwo = assignmentTwo.getText();
                             assignTwo[i] = Double.parseDouble(aTwo);
                             assignmentTwo.setText(" "+assignTwo[i]);
                             String aThree = assignmentThree.getText();
                             assignThree[i] = Double.parseDouble(aThree);
                             assignmentThree.setText(" "+assignThree[i]);
                             String gOne = examOne.getText();
                             gradeOne[i] = Double.parseDouble(gOne);
                             examOne.setText(" "+gradeOne[i]);
                             String gTwo = examTwo.getText();
                             gradeTwo[i] = Double.parseDouble(gTwo);
                             examTwo.setText(" "+gradeTwo[i]);
                             averageO[i] = (assignOne[i]+assignTwo[i]+assignThree[i])/3;
                             averageT[i] = (gradeOne[i]+gradeTwo[i])/2;
                             tAverage[i] = (averageO[i]+averageT[i])/2;
                             if (tAverage[i] >= Double.parseDouble(gradeA.getText())){
                                  letterGrade[i] = 'A';
                             }else if(tAverage[i] >= Double.parseDouble(gradeB.getText())){
                                  letterGrade[i] = 'B';
                             }else if(tAverage[i] >= Double.parseDouble(gradeC.getText())){
                                  letterGrade[i] = 'C';
                             }else if(tAverage[i] >= Double.parseDouble(gradeD.getText())){
                                  letterGrade[i] = 'D';
                             }else if(tAverage[i] <= Double.parseDouble(gradeE.getText())){
                                  letterGrade[i] = 'E';
              public void refresh(){
                   Student currentStudent = students[current];
                   studentsName.setText(currentStudent.getStudentName());
                   assignmentOne.setText(currentStudent.getAssignOne()+"");
                   assignmentTwo.setText(currentStudent.getAssignTwo()+"");
                   assignmentThree.setText(currentStudent.getAssignThree()+"");
                   examOne.setText(currentStudent.getExamOneGrade()+"");
                   examTwo.setText(currentStudent.getExamTwoGrade()+"");
              public static void main(String[]args){
                   GradeCalculator calWindow = new GradeCalculator();
                   calWindow.setVisible(true);
    Second class implemented./**
    *Group CAPE Computer Science 2007/8
    *Student.java
    *@author Carlson Smith
    *@version 3.01          07/02/2008
    public class Student {
         private String studentName;
         private double assignOne;
         private double assignTwo;
         private double assignThree;
         private double examOneGrade;
         private double examTwoGrade;
         public Student(String sName){
              studentName = sName;     
         public String getStudentName(){
              return studentName;
         public double getAssignOne(){
              return assignOne;
         public double getAssignTwo(){
              return assignTwo;
         public double getAssignThree(){
              return assignThree;
         public double getExamOneGrade(){
              return examOneGrade;
         public double getExamTwoGrade(){
              return examTwoGrade;
         public void setStudentName(String sName){
              studentName = sName;
         public void setAssignOne(double assignOne){
              this.assignOne = assignOne;
         public void setAssignTwo(double assignTwo){
              this.assignTwo = assignTwo;
         public void setAssignThree(double assignThree){
              this.assignThree = assignThree;
         public void setExamOneGrade(double examOneGrade){
              this.examOneGrade = examOneGrade;
         public void setExamTwoGrade(double examTwoGrade){
              this.examTwoGrade = examTwoGrade;
         public double getAverage(){
              return (assignOne + assignTwo + assignThree)/3;
         public double getExamAverage(){
              return (examOneGrade + examTwoGrade)/2;
         public double getTotalAverage(){
              return (getAverage() + getExamAverage())/2;
    this thread can be closed now. l8rz :P
    Edited by: Jacal on Feb 10, 2008 7:28 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         

  • Need Help In "Custom" TopBar Class

    New to Plumtree and need help to get rolling. Req's is simple thus far: To supress render of "Login" link in TopBarView for Guests if certain URL is captured at Request.
    There were some topics here that suggests extending from the Class PlumtreeTopBarView.CS, I just need to identify which UI part that renders the "Login" html link to supress this. I got the function to use to capture the URL string -> GetRequestURL(), I am fishing info on where or what function in PlumtreeTopBarView I need to override to plugin a condition that if this URL string == <something> then suppress "Login" link, or the Search, or whatever elements in the TopBar I need to suppress if need be??
    Is there some Help file in PT that I can reference that will enable me to find what namespace does GetRequestURL() belongs to? Please bear with me I am very new to PT code infrastructure, still trying to find stuff with strict deadlines. Much Obliged in advance...

    You just need to create your own version of PlumtreeTopBarView (original in com.plumtree.common.uiparts), and use CustomActivitySpace.xml to override that view with your own view. Your version would use some kidn fo logic to determine whether or not to display certain elements. TheUI Customization Guide should help quite a bit, and we have several quickstarts for overriding views you can start from.
    Is there some Help file in PT that I can reference that will enable me to find what namespace does GetRequestURL() belongs to?I would simply do a string compare. Tokenize the URL into the base address / control arguments, perhaps splitting on the "?" symbol; then tokenize the base address on the ".". You'll end up with three strings. For portal.plumtree.com, the three strings would portal, plumtree, and com. You can then use those string in the logig you add to PlumtreeTopBarView.
    David Phipps
    Plumtree Software

  • Need help with User defined class

    I need to create two Java classes. The first class will be used as a template for objects which represent students, the second will be a program which creates two student object and calls some of their methods.
    Create a file called "Student.java" and in it definr a class called Student which has the following Attributes:
    * a String variable which can hold the student's name
    * a double variable which can hold the studnet's exam mark.
    In the student class, define public methods as follows:
    1 a constructor method which accepts no arguments. This method should initialise the student's name to "unknown" and set the examination mark to zero
    2 A constructor method which accepts 2 arguments- the first being a string representing the student's name and the other being a double which represents their exam mark. These arguments should be used to initialise the state variables with one proviso- the exam mark must not be set to a number outside the range 0...100. If the double argument is outside this range,set the exam mark attribute to 0.
    3 A reader method which returns the students name
    4 A reader method which returns the students exam mark.
    5 A writer method which sets the student's name
    6 A writer method which sets the student's eeam mark. If the exam mark argument is outside the the 0...100 range,the exam mark attibute should not be modified.
    7 A method which returns the studnet's grade. The grade is a string such as "HD" or "FL" which can be determined from the following table.
    Grade Exam Mark
    HD 85..100
    DI 75..84
    CR 65..74
    PS 50..64
    FL 0..49
    Part2 Client Code
    Write a program in a file called "TestStudent.java"
    Make sure the file is in the same directory as tne "Student.java" file
    In the main method of "TestStudent.java" write code to do each of the following tasks
    1 Create a student object using the no argument constructor.
    2 Print this student's name and their exam mark
    3 Create another student object using the other constructor-supply your own name as the string argument and whatever exam mark you like as the double argument
    4 Print this studnet's name and their exam mark
    5 Change the exam mark of this student to 50 and print their exam mark and grade.
    6 Change the examination mark of this studnet to 256 and print their exam mark and grade.
    Can someone please help
    goober

    Sorry, I have sent you the wrong version. Try this,
    public class Student {
         private String name;
         private double examMark;
         public Student() {
              name = "unknown";
              examMark = 0.0;
         public Student(String n, double em) {
              name = n;
              if(em >0 && em < 100) {
                   examMark = em;
              } else {
                   examMark = 0.0;
         public String getName() {
              return name;
         public void setName(String n) {
              name = n;
         public double getExamMark() {
              return examMark;
         public void setExamMark(double em) {
              if(em >0 && em < 100) {
                   examMark = em;
              } else {
                   examMark = 0.0;
         public String getGrade() {
              if ( examMark > 84) return "HD";
              else if(examMark > 74) return "DI";
              else if(examMark > 64) return "CR";
              else if(examMark > 49) return "PS";
              else return "FL";
    } and
    class TestStudent {
         public static void main(String a[]) {
              Student st = new Student();
              System.out.println("Student Name is : "+st.getName());
              System.out.println("Student Marks is : "+st.getExamMark());
              Student st1 = new Student("XXXX",78);
              System.out.println("Student Name is : "+st1.getName());
              System.out.println("Student Marks is : "+st1.getExamMark());
              st1.setExamMark(67);
              System.out.println("Student Marks is : "+st1.getExamMark());
              System.out.println("Student Grade is : "+st1.getGrade());
              st1.setExamMark(256);
              System.out.println("Student Marks is : "+st1.getExamMark());
              System.out.println("Student Grade is : "+st1.getGrade());
    }Hope this helps.
    Sudha

  • Need help with Kerb. jdbc from Linux to MS SQL 2008

    Hello Forum, I am getting an erro when I try to use Kerb. trusted security to connect to sql server.
    4.0 documentation reflects it's absolutely possible.
    Not only that, I have ms odbc installed on the same box and it provides Kerbers (not ntlm) connection to sql server. But java with jdbc reject doing it.
    Here is the message:
    com.microsoft.sqlserver.jdbc.SQLServerException: Integrated authentication failed. ClientConnectionId:5836ac6c-6d2e-42e4-8c6d-8b89bc0be5c9
            at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:1667)
            at com.microsoft.sqlserver.jdbc.KerbAuthentication.intAuthInit(KerbAuthentication.java:140)
            at com.microsoft.sqlserver.jdbc.KerbAuthentication.GenerateClientContext(KerbAuthentication.java:268)
            at com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(SQLServerConnection.java:2691)
            at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:2234)
            at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$000(SQLServerConnection.java:41)
            at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:2220)
            at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:5696)
            at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1715)
            at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1326)
            at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:991)
            at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:827)
            at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1012)
            at java.sql.DriverManager.getConnection(DriverManager.java:419)
            at java.sql.DriverManager.getConnection(DriverManager.java:367)
            at connectURL.main(connectURL.java:53)
    Caused by: javax.security.auth.login.LoginException: unable to find LoginModule class: com.sun.security.auth.module.Krb5LoginModule
            at javax.security.auth.login.LoginContext.invoke(LoginContext.java:834)
            at javax.security.auth.login.LoginContext.access$000(LoginContext.java:209)
            at javax.security.auth.login.LoginContext$4.run(LoginContext.java:709)
            at java.security.AccessController.doPrivileged(AccessController.java:327)
            at javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:706)
            at javax.security.auth.login.LoginContext.login(LoginContext.java:603)
            at com.microsoft.sqlserver.jdbc.KerbAuthentication.intAuthInit(KerbAuthentication.java:133)
    1] Client side:
    Which OS platform are you running on? (Linux)
    Which JVM are you running on? (IBM J9 VM (build 2.6, JRE 1.6.0 Linux amd64-64
    What is the connection URL in you app? (jdbc:sqlserver://abcde24243.somebank.COM:15001;databaseName=master;integratedSecurity=true;authenticationScheme=JavaKerberos)
    If client fails to connect, what is the client error messages? (see above)
    Is the client remote or local to the SQL server machine? [Remote | Local]
    Is your client computer in the same domain as the Server computer? (Same domain | Different domains | WorkGroup)
    [2] Server side:
    What is the MS SQL version? [ SQL Sever 2008]
    Does the server start successfully? [YES ] If not what is the error messages in the SQL server ERRORLOG?
    If SQL Server is a named instance, is the SQL browser enabled? [NO]
    What is the account that the SQL Server is running under?[Domain Account]
    Do you make firewall exception for your SQL server TCP port if you want connect remotely through TCP provider? [YES ]
    Do you make firewall exception for SQL Browser UDP port 1434? In SQL2000, you still need to make firewall exception for UDP port 1434 in order to support named instance.[YES | NO | not applicable ]
    I currently can login from client using ms odbc sqlcmd (linux) version with trusted Kerberos connection.
    which tells me there is no problem with firewall.
    Tips:
    If you are executing a complex statement query or stored procedure, please use execute() instead of executeQuery().
    If you are using JDBC transactions, do not mix them with T-SQL transactions.
    Last but not least:
    gene

    Saeed,
    Not being versed in JAVA, I'm not sure what you're telling me. Can you tell me if this looks good? BTW, I did find out that JDBC is installed on the server as part of Coldfusion and this is what I was told:
    macromedia.jdbc.oracle.OracleDriver is 3.50
    macromedia.jdbc.db2.DB2Driver is 3.50
    macromedia.jdbc.informix.InformixDriver is 3.50
    macromedia.jdbc.sequelink.SequeLinkDriver is 5.4
    macromedia.jdbc.sqlserver.SQLServerDriver is 3.50
    macromedia.jdbc.sybase.SybaseDriver is 3.50
    Below is what I think will work, but I know it won't because of the semi colons. Can you help me fix it?
    I've the things that I think need changing are in bold.
    Thanks!
    ======
    private void dbInit()
    dbUrl = "jdbc:odbc:DRIVER={SQL Server};Database="DATADEV";Server=VS032.INTERNAL.COM:3533;", "web_user";
    try
    Class.forName("macromedia.jdbc.sqlserver.SQLServerDriver ");
    catch(Exception eDriver)
    failedDialog("Driver failed!", eDriver.getMessage());
    private void dbOpen()
    if(paramServerIP.indexOf("datadev") >= 0)
    dbPswd = "password";
    else
    dbPswd = "password";
    try
    dbCon = DriverManager.getConnection(dbUrl, paramDbUserStr,
    dbPswd);
    dbStmt = dbCon.createStatement();
    dbStmt.setEscapeProcessing(true);
    catch(Exception eDbOpen)
    failedDialog("Failed to open db connection!",
    eDbOpen.getMessage());
    private void dbClose()
    try
    dbStmt.close();
    dbCon.close();
    catch(Exception eDbClose)
    failedDialog("Failed to close db connection!",
    eDbClose.getMessage());
    }

  • Need help with Thin JDBC connecting Oracle to SQL server.

    I am fairly new to JAVA. We have ORACLE 8.1.7 running on Solaris 8. I have a need to
    periodically extract data from ORACLE DB and transfer it to SQL Server. I am limited to
    moving data from the ORACLE/UNIX environment to SQL Server side.
    From what I have read, Server-side Thin driver should work.
    1) Are there any issues in trying to achieve this with ORACLE running on the UNIX platform?
    2) Will the Server-side Thin driver talk to both the DBs ?
    3) Is it possible to provide some sample code ?
    Thanks in advance,
    Solomon

    Quattro,
    I had complete success in reading from Oracle and writing to SQL Server. First of all let me thank you for all your help. I do have one last request. Its more on optimization than any thing else.
    I was trying to optimize my code by grouping both the connections in one place and to keep my reads and inserts together so that I don't commit at the end of each insert etc. I don't seem to have the scope rules under control yet. Could you suggest how to improve this:
    import java.sql.*;
    public class Test_Combined2 {
    public static void main(String args[]) throws SQLException {
    // Load the Oracle JDBC driver
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    // Connect to the database
    // You must put a database name after the @ sign in the connection URL.
    // You can use either the fully specified SQL*net syntax or a short cut
    // syntax as <host>:<port>:<sid>. The example uses the short cut syntax.
    Connection con2 = DriverManager.getConnection ("jdbc:oracle:thin:@Test:1521:PSDEVElOP",
    "SOLOMON","SOL1");
    // Create a Statement
    Statement stmt2 = con2.createStatement ();
    String url = "jdbc:microsoft:sqlserver://INTRADEV:1433;DatabaseName=Measure";
    Connection con;
    String query = "select dataYear, dataMonth, yieldRate from tblYield " ;
    Statement stmt;
    try {
    Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
    } catch(java.lang.ClassNotFoundException e) {
    System.err.print("ClassNotFoundException: ");
    System.err.print(e.getMessage());
    // Select the ENAME column from the EMP table
    ResultSet rset = stmt2.executeQuery ("select year_start, monthofyear, percent_comp " +
    " from ps_usm_ytd_yield ");
    // Iterate through the result and print the employee names
    while (rset.next ()) {
    System.out.println (rset.getFloat (3));
    int ps_dataYear = rset.getInt(1);
    int ps_dataMonth = rset.getInt(2);
    float ps_yieldRate = rset.getFloat(3);
    try{
    con = DriverManager.getConnection (url, "tmpuser","tmppush");
    stmt = con.createStatement();
    PreparedStatement insertTblYield;
    String insertString = "insert into tblYield " +
    " values(?, ?, ?)";
    //con.setAutoCommit(false);
    insertTblYield = con.prepareStatement(insertString);
    insertTblYield.setInt(1, ps_dataYear);
    insertTblYield.setInt(2, ps_dataMonth);
    insertTblYield.setFloat(3, ps_yieldRate);
    insertTblYield.executeUpdate();
    con.commit();
    //con.setAutoCommit(false);
    /*ResultSet rs = stmt.executeQuery(query);
    System.out.println("dataYear, dataMonth, yieldRate");
    while (rs.next()) {
    int dataYear = rs.getInt(1);
    int dataMonth = rs.getInt(2);
    float yieldRate = rs.getFloat(3);
    System.out.println(" " + dataYear + ", " + dataMonth + ", " + yieldRate);
    stmt.close();
    con.close();
    } catch(SQLException ex) {
    System.err.print("SQLException: ");
    System.err.println(ex.getMessage());
    } //while
    stmt2.close();
    con2.close();

  • Need HELP with objects and classes problem (program compiles)

    Alright guys, it is a homework problem but I have definitely put in the work. I believe I have everything right except for the toString method in my Line class. The program compiles and runs but I am not getting the right outcome and I am missing parts. I will post my problems after the code. I will post the assignment (sorry, its long) also. If anyone could help I would appreciate it. It is due on Monday so I am strapped for time.
    Assignment:
    -There are two ways to uniquely determine a line represented by the equation y=ax+b, where a is the slope and b is the yIntercept.
    a)two diffrent points
    b)a point and a slope
    !!!write a program that consists of three classes:
    1)Point class: all data MUST be private
    a)MUST contain the following methods:
    a1)public Point(double x, double y)
    a2)public double x ()
    a3public double y ()
    a4)public String toString () : that returns the point in the format "(x,y)"
    2)Line class: all data MUST be private
    b)MUST contain the following methods:
    b1)public Line (Point point1, Point point2)
    b2)public Line (Point point1, double slope)
    b3)public String toString() : that returns the a text description for the line is y=ax+b format
    3)Point2Line class
    c1)reads the coordinates of a point and a slope and displays the line equation
    c2)reads the coordinates of another point (if the same points, prompt the user to change points) and displays the line equation
    ***I will worry about the user input later, right now I am using set coordinates
    What is expected when the program is ran: example
    please input x coordinate of the 1st point: 5
    please input y coordinate of the 1st point: -4
    please input slope: -2
    the equation of the 1st line is: y = -2.0x+6.0
    please input x coordinate of the 2nd point: 5
    please input y coordinate of the 2nd point: -4
    it needs to be a diffrent point from (5.0,-4.0)
    please input x coordinate of the 2nd point: -1
    please input y coordinate of the 2nd point: 2
    the equation of the 2nd line is: y = -1.0x +1.0
    CODE::
    public class Point{
         private double x = 0;
         private double y = 0;
         public Point(){
         public Point(double x, double y){
              this.x = x;
              this.y = y;
         public double getX(){
              return x;
         public double setX(){
              return this.x;
         public double getY(){
              return y;
         public double setY(){
              return this.y;
         public String toString(){
              return "The point is " + this.x + ", " + this.y;
    public class Line
         private double x = 0;
         private double y = 0;
         private double m = 0;
         private double x2 = 0;
         private double y2 = 0;
         public Line()
         public Line (Point point1, Point point2)
              this.x = point1.getX();
              this.y = point1.getY();
              this.x2 = point2.getX();
              this.y2 = point2.getY();
              this.m = slope(point1, point2);
         public Line (Point point1, double slope)
              this.x = point1.getX();
              this.y = point1.getY();
         public double slope(Point point1, Point point2)//finds slope
              double m1 = (point1.getY() - point2.getY())/(point1.getX() - point2.getX());
              return m1;
         public String toString()
              double temp = this.x- this.x2;
              return this.y + " = " +temp + "" + "(" + this.m + ")" + " " + "+ " + this.y2;
              //y-y1=m(x-x1)
    public class Point2Line
         public static void main(String[]args)
              Point p = new Point(3, -3);
              Point x = new Point(10, 7);
              Line l = new Line(p, x);
              System.out.println(l.toString());
    }My problems:
    I dont have the right outcome due to I don't know how to set up the toString in the Line class.
    I don't know where to put if statements for if the points are the same and you need to prompt the user to put in a different 2nd point
    I don't know where to put in if statements for the special cases such as if the line the user puts in is a horizontal or vertical line (such as x=4.7 or y=3.4)
    Edited by: ta.barber on Apr 20, 2008 9:44 AM
    Edited by: ta.barber on Apr 20, 2008 9:46 AM
    Edited by: ta.barber on Apr 20, 2008 10:04 AM

    Sorry guys, I was just trying to be thorough with the assignment. Its not that if the number is valid, its that you cannot put in the same coordinated twice.
    public class Line
         private double x = 0;
         private double y = 0;
         private double m = 0;
         private double x2 = 0;
         private double y2 = 0;
         public Line()
         public Line (Point point1, Point point2)
              this.x = point1.getX();
              this.y = point1.getY();
              this.x2 = point2.getX();
              this.y2 = point2.getY();
              this.m = slope(point1, point2);
         public Line (Point point1, double slope)
              this.x = point1.getX();
              this.y = point1.getY();
         public double slope(Point point1, Point point2)//finds slope
              double m1 = (point1.getY() - point2.getY())/(point1.getX() - point2.getX());
              return m1;
         public String toString()
              double temp = this.x- this.x2;
              return this.y + " = " +temp + "" + "(" + this.m + ")" + " " + "+ " + this.y2;
              //y-y1=m(x-x1)
    public class Point2Line
         public static void main(String[]args)
              Point p = new Point(3, -3);
              Point x = new Point(10, 7);
              Line l = new Line(p, x);
              System.out.println(l.toString());
    }The problem is in these lines of code.
    public double slope(Point point1, Point point2) //if this method finds the slope than how would i use the the two coordinates plus "m1" to
              double m1 = (point1.getY() - point2.getY())/(point1.getX() - point2.getX());
              return m1;
         public String toString()
              double temp = this.x- this.x2;
              return this.y + " = " +temp + "" + "(" + this.m + ")" + " " + "+ " + this.y2;
              //y-y1=m(x-x1)
         }if slope method finds the slope than how would i use the the two coordinates + "m1" to create a the line in toString?

  • Need help reg sender JDBC adapter

    Hi,
    I am having a requirement like, i need to fetch the data from two data base tables. and after fetching the data, i need to update those two tables.
    For selecting the data from two tables, two select statements i need to write, how i can give two select statements in sender JDBC comm channel.
    In sender JDBC channel, only one update query we can give...how i can update two tables?
    Regards,
    Venkata Ramana.

    Hello Venkat,
    For your requirement, go for stored procedure and find the below thread.
    Fetching data from JDBC without using JDBC sender adapter
    Re: Executing an Oracle Stored Procedure from Sender JDBC adapter
    Re: Sender JDBC adapter not picking up data
    Re: Retrive data from two diffirent tables
    hope this will help you
    Thanks,
    Venky

  • Need help in DB2 JDBC connection from JDeveloper extension

    Hi,
    I am using JDeveloper extension to build my application. Here in the preferences, I have a UI in which I need to specify DB2 database connection parameters for establishing JDBC connection. After copying the required driver jar and license jar to the extension folder and specifying the CLASSPATH in extension.xml file, I am able to get the DB Connection. But the issue here is, I do not want the user to copy the driver jars to the extension path and neither to hardcode the driver CLASSPATH in extension.xml. Instead, if the user loads the driver jar in the CLASSPATH using command line, after launching JDev plug-in, I need to still be able to connect to the DB2 JDBC which is not happening. I am getting the error which says "Missing class com.ibm.db2.jcc.DB2Driver". I have ensured that the CLASSPTH is set for the driver and licensing jars for DB2. How can I get rid of this error without specifying the classpath in extension.xml file.
    Thanks,
    Sudha.
    Edited by: sudha.singh on Dec 13, 2010 1:08 AM
    Edited by: sudha.singh on Dec 13, 2010 1:08 AM

    drivers for DB2 for the JDBC adapter.
    1. db2jcc.jar
    2. db2_license_cu.jar
    3. db2_license_cisuz.jar
    Driver = com.ibm.db2.jcc.DB2Driver
    URL = jdbc:db2://<hostname>:5021/<dbname>:
    http://publib.boulder.ibm.com/infocenter/db2luw/v8/index.jsp?topic=/com.ibm.db2.udb.doc/ad/rjvjcdif.htm
    http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=/com.ibm.db2.udb.apdv.java.doc/doc/t0010264.htm

  • Need help in using Runtime class

    Hi all,
    I am facing problem with JRE versions of websphere and SUN JRE. Let me explain my problem.
    We have an application working fine in websphere, Now my organization wants to migrate this app to websphere. This application downloads some set of jar files to the client side when the user hits the server with some url. These jar files starts th swing based application in the client side , at the same it will try to communicate with EJB's deployed in the server(Now websphere) to get the data for menus and trees in the swing application. Because of different JRE in the websphere commucation problems like class cast exception are happening. Now we are downloading the the Websphere JRE to the client side and trying to start the application with the downloaded JRE(Even it is not required in case of weblogic in the exiting application also they are downloading the sun JRE). Here the problem starts for me. The execute method of Process class is not able to detect the main class. The waitFor method is returning non zero value. Here is my method.
    Can anybody guess what's wrong going on with this code.
    public Process spawnProcess(String szSpawnCommand) throws
    Exception
              szSpawnCommand = "C:\\ccc\\JRE\\bin\\javaw.exe com.att.suite.client.SuiteAppManager";
              System.out.println("starting processs "+szSpawnCommand);
    Process oProcess = null;
    try
    // oProcess = Runtime.getRuntime().exec(szSpawnCommand);
         Runtime rt = Runtime.getRuntime();
         System.out.println("Got runtime.....");
         oProcess = rt.exec("c:/ccc/JRE/bin/java com.att.suite.client.SuiteAppManager");
         //oProcess.waitFor();
    //oProcess = rt.exec("c:/ccc/JRE/bin/javaw -version");
    catch (Exception ex)
    // Throw an exception with the reason why the process
    // couldn't be spawned
    // The original message here confused end users - almost always
    // occurs due to lack of memory and we cannot determine actual
    // reason OS failed to spawn a process.
    // Changed to correct LCR MR#: 437
    // throw new Exception("Unable to spawn process with command: \"" +
    // szSpawnCommand + "\".\nSystem Reason: " + ex.getMessage());
    /*throw new Exception("You have insufficient memory to " +
    "launch this program. \nPlease quit some other " +
    "applications and try again.");*/
         System.out.println("In oProcess.... ");
    ex.printStackTrace();
    // Wait for a second to give the new process a chance
    // to run properly
    try
    Thread.sleep(1000);
    catch (Exception ex)
    final DataInputStream oProcStdOutStream = new DataInputStream(
    oProcess.getInputStream());
    final DataInputStream oProcStdErrStream = new DataInputStream(
    oProcess.getErrorStream());
    Thread oProcStdOutStreamThread = new Thread()
    public void run()
    try
    String szLine = null;
    while ((szLine = oProcStdOutStream.readLine()) != null)
    System.out.println("[FromProc1] " + szLine);
    catch (Exception ex)
         System.out.println("In oProcStdOutStream");
    ex.printStackTrace();
    oProcStdOutStreamThread.start();
    Thread oProcStdErrStreamThread = new Thread()
    public void run()
    try
    String szLine;
    while ((szLine = oProcStdErrStream.readLine()) != null)
    System.out.println("[FromProc2] " + szLine);
    catch (Exception ex)
    ex.printStackTrace();
    oProcStdErrStreamThread.start();
    // See if the process is still running properly
    int nProcessExitValue = 0;
    try
    nProcessExitValue = oProcess.exitValue();
         // nProcessExitValue = oProcess.waitFor();
         System.out.println("nProcessExitValue : "+nProcessExitValue);
    catch (Exception ex)
    // This means that the process is still running which
    // we'll consider a good sign.
    nProcessExitValue = 0;
    System.out.println("In nProcessExitValue");
    ex.printStackTrace();
    // Check the process exit value
    if (nProcessExitValue != 0)
    // Throw an exception with the return value of the spawned
    // process.
    // The original message here confused end users - almost always
    // occurs due to lack of memory and we cannot determine actual
    // reason OS failed to spawn a process.
    // Changed to correct LCR MR#: 437
    // throw new Exception("Unable to spawn process with command: \"" +
    // szSpawnCommand + "\".\nProcess Exit Value: " +
    // nProcessExitValue);
    throw new Exception("You have insufficient memory to " +
    "launch this program. \nPlease quit some other " +
    "applications and try again.");
         //System.out.println("In nProcessExitValue!=0");
    Here is the error :
    starting processs C:\ccc\JRE\bin\javaw.exe com.att.suite.client.SuiteAppManager
    Class loaded...
    Got runtime.....
    nProcessExitValue : 1
    [FromProc2] The java class is not found: com/att/launch/jre/Sample
    java.lang.Exception: You have insufficient memory to launch this program.
    Please quit some other applications and try again.
         at com.att.launch.jre.LaunchApp.spawnProcess(LaunchApp.java:525)
         at com.att.launch.jre.LaunchApp.spawnCJAS(LaunchApp.java:366)
         at com.att.launch.jre.LaunchApp.main(LaunchApp.java:171)
    Please help me, I am struggling with this problem from the long time. Or can any body suggest different way to solve this problem instead of downloading the JRE to the client side.
    Bhaskar

    Hi ,
    I am facing problem with JRE versions of websphere and SUN JRE. Let me explain my problem.
    We have an application working fine in websphere, Now my organization wants to migrate this app to websphere. This application downloads some set of jar files to the client side when the user hits the server with some url. These jar files starts th swing based application in the client side , at the same it will try to communicate with EJB's deployed in the server(Now websphere) to get the data for menus and trees in the swing application. Because of different JRE in the websphere commucation problems like class cast exception are happening.
         Now we are downloading the the Websphere JRE to the client side and trying to start the application with the downloaded JRE(Even it is not required in case of weblogic in the exiting application also they are downloading the sun JRE).
    Here the problem starts for me. The execute method of Process class is not able to detect the main class. The waitFor method is returning non zero value. Here is my method.
    Can anybody guess what's wrong going on with this code
    public Process spawnProcess(String szSpawnCommand) throws
    Exception
              System.out.println("starting processs "+szSpawnCommand);
    Process oProcess = null;
    try
         Runtime rt = Runtime.getRuntime();
         System.out.println("Got runtime.....");
         oProcess = rt.exec("c:/ccc/JRE/bin/java com.att.suite.client.SuiteAppManager");
    catch (Exception ex)
    throw new Exception("You have insufficient memory to " +
    "launch this program. \nPlease quit some other " +
    "applications and try again.");      
    // Wait for a second to give the new process a chance
    // to run properly
    try
    Thread.sleep(1000);
    catch (Exception ex)
    final DataInputStream oProcStdOutStream = new DataInputStream(oProcess.getInputStream());
    final DataInputStream oProcStdErrStream = new DataInputStream(oProcess.getErrorStream());
    Thread oProcStdOutStreamThread = new Thread()
    public void run()
    try
    String szLine = null;
    while ((szLine = oProcStdOutStream.readLine()) != null)
    System.out.println("[FromProc1] " + szLine);
    catch (Exception ex)
         System.out.println("In oProcStdOutStream");
    ex.printStackTrace();
    oProcStdOutStreamThread.start();
    Thread oProcStdErrStreamThread = new Thread()
    public void run()
    try
    String szLine;
    while ((szLine = oProcStdErrStream.readLine()) != null)
    System.out.println("[FromProc2] " + szLine);
    catch (Exception ex)
    ex.printStackTrace();
    oProcStdErrStreamThread.start();
    // See if the process is still running properly
    int nProcessExitValue = 0;
    try
    nProcessExitValue = oProcess.exitValue();
         // nProcessExitValue = oProcess.waitFor();
         System.out.println("nProcessExitValue : "+nProcessExitValue);
    catch (Exception ex)
    // This means that the process is still running which
    // we'll consider a good sign.
    nProcessExitValue = 0;
    System.out.println("In nProcessExitValue");
    ex.printStackTrace();
    // Check the process exit value
    if (nProcessExitValue != 0)
    throw new Exception("You have insufficient memory to " +
    "launch this program. \nPlease quit some other " +
    "applications and try again.");
    Here is the error :
    starting processs C:\ccc\JRE\bin\javaw.exe com.att.suite.client.SuiteAppManager
    Class loaded...
    Got runtime.....
    nProcessExitValue : 1
    [FromProc2] The java class is not found: com/att/launch/jre/Sample
    java.lang.Exception: You have insufficient memory to launch this program.
    Please quit some other applications and try again.
         at com.att.launch.jre.LaunchApp.spawnProcess(LaunchApp.java:525)
         at com.att.launch.jre.LaunchApp.spawnCJAS(LaunchApp.java:366)
         at com.att.launch.jre.LaunchApp.main(LaunchApp.java:171)
    Please help me, I am struggling with this problem from the long time. Or can any body suggest different way to solve this
    problem instead of downloading the JRE to the client side.
    Bhaskar

  • Need help with my diffydriver class!!!

    I nee help! here is my code: http://pastebin.com/f3616165
    An example: if you enter these four numbers: 10, 7, 2, 2 to the prompts in main, your program should print
    10 7 2 2
    3 5 0 8
    2 5 8 5
    3 3 3 3
    0 0 0 0
    my problem is my printDiffy method

    Sorry for the trouble, I try to go to the irc ##java chat, and had it pasted to the paste-bin web site:
    import java.util.Scanner;
    public class diffydriver {
    * @param args the command line arguments
    public static void main(String[] args) {
    Scanner console = new Scanner(System.in);
    int n1,n2,n3,n4;
    System.out.println("Enter four integer" +
    "initial values. Separate each one by a space: ");
    n1 = console.nextInt();
    n2 = console.nextInt();
    n3 = console.nextInt();
    n4 = console.nextInt();
    Diffy d = new Diffy (n1, n2, n3, n4);
    d.printDiffy();
    System.out.println();
    do {
    d.next();
    d.printDiffy();
    while (d.isZero() == false);
    class Diffy {
    private int d1;
    private int d2;
    private int d3;
    private int d4;
    private Object d;
    public Diffy(int diffy1, int diffy2, int diffy3, int diffy4)
    d1 = diffy1;
    d2 = diffy2;
    d3 = diffy3;
    d4 = diffy4;
    public boolean isZero()
    if (!(d1 + d2 + d3 + d4 == 0))
    return false;
    else
    return true;
    public Diffy next()
    int a,b,c,e;
    a = Math.abs(this.d1 - this.d2);
    b = Math.abs(this.d2 - this.d3);
    c = Math.abs(this.d3 - this.d4);
    e = Math.abs(this.d4 - this.d1);
    Diffy w = new Diffy(a,b,c,e);
    return w;
    void printDiffy() {
    //d = null;
    d = d.next();
    }

  • Need help setting up JDBC with mySQL and Netbeans

    I've successfully got mySQL up and running and created a few simple test databases. I've been following the instructions on this website (http://www.stardeveloper.com/articles/display.html?article=2003090401&page=1 ) to get JDBC working but have had little luck.
    I've downloaded JDBC from mySQL website, extracted the mysql-connector-java-3.1.13-bin.jar file and changed the class path to :
    C:\Program Files\Java\jre1.5.0_06\lib\ext\mysql-connector-java-3.1.13-bin
    which is where I placed the .jar file.
    I then used the following code provided on stardeveloper.com to test a connection with the test database.
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    public class JdbcExample2 {
      public static void main(String args[]) {
        Connection con = null;
        try {
          Class.forName("com.mysql.jdbc.Driver").newInstance();
          con = DriverManager.getConnection("jdbc:mysql:///test",
            "root", "secret");
          if(!con.isClosed())
            System.out.println("Successfully connected to " +
              "MySQL server using TCP/IP...");
        } catch(Exception e) {
          System.err.println("Exception: " + e.getMessage());
        } finally {
          try {
            if(con != null)
              con.close();
          } catch(SQLException e) {}
    }It compiles but when run I get the error message :
    java.lang.NoClassDefFoundError: testdatabase/JdbcExample2
    Exception in thread "main"I assume this means that my classpath isn't setup correctly but I have no idea what's up and how to correct it.
    Can someone PLEASE tell me how to setup jdbc and what I've done wrong.
    Thanks in advance :)

    Thanks for your reply. I've made some progress but I'm still having problems.
    In mySQL I created a new user called uraknai with password n0121429 and granted them access to a test database I created called pet.
    Then, in netbeans, I clicked the Runtime tab, clicked Databases and rightclicked Drivers and clicked Add Driver. I then added the driver mysql-connector-java-3.1.13-bin.jar. I then right clicked the newly added driver and selected the connect using option. I filled in the appropriate boxes clicked ok and it connected successfully.
    Then, under the project tab, I right clicked the project name, clicked properties then clicked Libraries and added the .jar file mysql-connector-java-3.1.13-bin.jar
    I then ran the following code to test the connection to the database:
    import java.sql.*;
    public class ConnectionTest {
        public ConnectionTest() {
        public static void main(String[] args)
            System.out.println("BEGIN CONNECTION TEST");
            Connection conn = null;
            try
                   String userName = "uraknai";
                   String password = "n0121429";
                   String url = "jdbc:mysql://localhost/pet";
                   Class.forName ("com.mysql.jdbc.Driver").newInstance ();
                   conn = DriverManager.getConnection (url, userName, password);
                   System.out.println ("Database connection established");
             catch (Exception e)
                   System.err.println ("Cannot connect to database server");
             finally
                   if (conn != null)
                       try
                           conn.close ();
                           System.out.println ("Database connection terminated");
                       catch (Exception e) { /* ignore close errors */ }
    }and get the message:
    java.lang.NoClassDefFoundError: math/ConnectionTest
    Exception in thread "main"
    Java Result: 1when I run the code.
    Can someone explin what I've done wrong and how to fix the problem.
    Cheers.

  • Need Help !! JDBC ....is this working ?

    Hi,
    i am new to java and would like to know if this is a correct working script for database access ? Can you please take a look ?
    Class.forName(com.sybase.jdbc.SybDriver);
    Connection jdbcConnection =
    DriverManager.getConnection
    ("jdbc:sybase:Tds:10.10.10.10:4100/testdb","login","passwd");
    Statement sqlStatement = jdbcConnection.createStatement();
    String sql = "SELECT * FROM Test";
    try
    ResultSet results = sqlStatement.executeQuery(sql);
    while (results.next())
    System.our.println("Field One: " +
    results.getString(1) +
    "Field Two: " +
    results.getString(2) +
    "Field Three: " +
    results.getString(3));
    catch (Exception e)
    System.out.println("Error: " + e);
    Does this work ?
    TIA

    Only a small syntax error
    Class.forName(com.sybase.jdbc.SybDriver);
    should be
    Class.forName("com.sybase.jdbc.SybDriver");
    Your syntax seems correct .... but there are a few other things that are required for this to work.
    1] the SybDriver
    2] the database name and url in
    DriverManager.getConnection
    ("jdbc:sybase:Tds:10.10.10.10:4100/testdb","login","passwd");
    3] the login and passwd must be valid in the testdb database.
    If you have these things as given in the code ... then PARTY !!!!!

  • I need help with the https class please.

    Hello, i need add an authentication field in my GET request using HTTPS to authenticate users. I put the authentication field using the setRequestProperty method, but it doesn't appear when i print all properties using the getRequestProperties method. I wrote the following code:
    try{
    URL url = new URL ("https://my_url..");
    URLConnection conexion;
    conexion = url.openConnection();
    conexion.setRequestProperty("Authorization",my_urlEncoder_string);
    conexion.setRequestProperty("Host",my_loginServer);
    HttpsURLConnection httpsConexion = (HttpsURLConnection) conexion;
    httpsConexion.setRequestMethod("GET");
    System.out.println("All properties\r\n: " + httpsConexion.getRequestProperties());
    }catch ....
    when i run the program it show the following text:
    All properties: {Host=[my_loginServer]}
    Only the Host field is added to my HttpsURLConnection. The authentication field doesnt appear in standar output. How can i add to my HttpsURLConnection an Authentication field?
    thanks

    I have moved this to the main Dreamweaver forum, as the other forum is intended to deal with the Getting Started video tutorial.
    The best way to get help with layout problems is to upload the files to a website and post the URL in the forum. Someone can then look at the code, and identify the problem. Judging from your description, it sounds as though the Document window is narrow, which would result in the final menu tab dropping down to the next row. Try turning on Live view or previewing the page in a browser. Design view gives only an approximate idea of the final layout. Live view renders the page as it should look in a browser.

Maybe you are looking for

  • Contract Release Value is not updated with Confirmation or Invoice value

    The release value for a contract in SRM EBP shows the value of purchase orders created using that contract.  It does not take into account confirmation and/or invoice values. For example I create a PO for 10 items at £100/each using Contract ABC.  Th

  • Substr function problem in oracle

    my requirement is that i am writing the stored procedure in which use *substr( source_string, start_position, [ length ] )* my 1 requirement i have i problem that the source_string is dynamically being passed as a parameter into the stored procedure

  • Conversion Planned Order - Purchase Requisition

    Hi Gurus, how can I convert one or more Planned Orders in only one Purchase Requisition? Thanks, Marco

  • Authorization Issue with VA01 and  VA02

    Dear Experts, I have request to restrict onl;y three users to view the "payement terms" coloum in VA01 and VA02. I could not able to find the relavent authorization object. please advise. Regards Suneetha

  • Popup children in AIR

    My application alters the dragProxy image for certain components depending on the target the user drags over. I've gotten this to work great within Flash Player -- in my dragOverHandle I manipulate event.dragInitiator.systemManager.popUpChildren.getC