Need help - select data from NCLOB column problem

Hi,
Im having problem retrieving data from NCLOB columns via ODBC. After SQLExecdirect on my SELECT statement call to SQLFetch gives me following error:
ORA-24806 LOB form mismatch
I tried following two ways of data retrieval:
SQLExecDirect(hstmt,(SQLTCHAR*)szSQLStatement,SQL_NTS);
SQLBindCol(hstmt,3,SQL_C_TCHAR,chBuffer,sizeof(chBuffer),&iDataLen);
SQLFetch(hstmt);
OR
SQLExecDirect(hstmt,(SQLTCHAR*)szSQLStatement,SQL_NTS);
SQLFetch(hstmt);
SQLGetData(hstmt,3,SQL_C_TCHAR,chBuffer,sizeof(chBuffer),&iDataLen);
Both times call to SQLFetch gives me ORA-24806 LOB form mismatch error.
INSERT and UPDATE for this table works just fine.
If I change NCLOB type to CLOB works just fine, but I will be storing Unicode data, so using CLOB cant be a solution
Any ideas appreciated.
Thanks in advance,
Vlad
Server:
Oracle 9.2 database on Windows 2000 Server
NLS_LANGUAGE = AMERICAN
NLS_TERRITORY = AMERICA
NLS_CHARACTERSET = WE8MSWIN1252
NLS_NCHAR_CHARACTERSET = AL16UTF16
Client:
Unicode C++ application, connects via Oracle 9.2 ODBC driver on Windows XP
NLS_LANG = AMERICAN_AMERICA.WE8MSWIN1252
CREATE TABLE my_nclob_table (
     id number (10,0) NOT NULL ,
     name nvarchar2 (255) NOT NULL ,
     description nvarchar2 (255) NULL ,
     definition nclob NOT NULL ,
     creation date NOT NULL ,
     lastmodified date NOT NULL ,
     CONSTRAINT PK_cat_pricelist PRIMARY KEY
          id
#define     nil NULL
#define     null NULL
#define     SQL_ERR(__sqlerr__)     (((__sqlerr__) != SQL_SUCCESS) && ((__sqlerr__) != SQL_SUCCESS_WITH_INFO))
#define     STOP_IF_SQL_ERR(__sqlerr__)                                                                 \
                                                  do                                                       \
                                                       if (SQL_ERR(__sqlerr__)) goto stop_;     \
                                                  } while (false)                                                  
void eqTestOracleLOBSelect(void)
     SQLHENV henv     = null;
     SQLHDBC hdbc     = null;
     SQLHSTMT hstmt     = null;
     SQLRETURN retcode     = SQL_SUCCESS;
     TCHAR          szSQLStatement[]     = T("select id, name, definition from mynclob_table");
     int               iFetchedRows = 0;
     TCHAR          szMsg[512];
     TCHAR          chBuffer[2049];
     SQLLEN          iDataLen = 0;
     try
          retcode = eqOpenConnectionODBC(_T("myTestDsn"),_T("user"),_T("pwd"),henv,hdbc);
          STOP_IF_SQL_ERR(retcode);
          retcode = SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &hstmt);
          STOP_IF_SQL_ERR(retcode);
          retcode = SQLExecDirect(hstmt,(SQLTCHAR*)szSQLStatement,SQL_NTS);
          STOP_IF_SQL_ERR(retcode);
          retcode = SQLBindCol(hstmt,3,SQL_C_TCHAR,chBuffer,sizeof(chBuffer),&iDataLen);
          STOP_IF_SQL_ERR(retcode);
               while (retcode == SQL_SUCCESS)
                    retcode = SQLFetch(hstmt);
                    if (retcode == SQL_NO_DATA)
                         retcode = SQL_SUCCESS;
                         break;
                    STOP_IF_SQL_ERR(retcode);
               //     retcode = SQLGetData(hstmt,3,SQL_C_TCHAR,chBuffer,sizeof(chBuffer),&iDataLen);
               //     STOP_IF_SQL_ERR(retcode);
                    ++iFetchedRows;
     stop_:
          if (SQL_ERR(retcode))
               MessageBox(null,_T("SQL statement execution error."),_T("Error"),MB_OK);
               eqShowStatementError(SQL_HANDLE_STMT,hstmt,retcode);
          } else     {
                         _stprintf(szMsg,_T("SQL execution success. Fetched rows: %ld"),iFetchedRows);
                         MessageBox(null,szMsg,_T("Success"),MB_OK);
     catch(...)
          MessageBox(null,_T("Unknown exception in eqTestOracleLOBSelect"),_T("Unknown exception"),MB_OK);
     if (hstmt != null)
          SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
          hstmt = null;
     if (hdbc != nil)
          SQLFreeHandle(SQL_HANDLE_DBC, hdbc);
          hdbc = nil;
     if (henv != nil)
          SQLFreeHandle(SQL_HANDLE_ENV, henv);
          henv = nil;
SQLRETURN eqOpenConnectionODBC(TCHAR          *szDSN,
                                   TCHAR          *szUser,
                                   TCHAR          *szPassword,
                                   SQLHENV     &henv,
                                   SQLHDBC &hdbc)
     SQLRETURN retcode;
     henv = nil;
     hdbc = nil;
     //Allocate environment handle
     retcode = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv);
     STOP_IF_SQL_ERR(retcode);
     //Set the ODBC version environment attribute
     retcode = SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION, (void*)SQL_OV_ODBC3, 0);
     STOP_IF_SQL_ERR(retcode);
     // Allocate connection handle
     retcode = SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc);
     STOP_IF_SQL_ERR(retcode);
     // Set login timeout to 5 seconds.
     SQLSetConnectAttr(hdbc, SQL_LOGIN_TIMEOUT, (void*)5, 0);
     STOP_IF_SQL_ERR(retcode);
     retcode = SQLConnect(hdbc, (SQLTCHAR*)szDSN, SQL_NTS,
                                        (SQLTCHAR*)szUser, SQL_NTS,
                                        (SQLTCHAR*)szPassword, SQL_NTS);
stop_:
          if (SQL_ERR(retcode))
               MessageBox(null,_T("Connection Error."),_T("Error"),MB_OK);
               if (hdbc != nil)
                    eqShowStatementError(SQL_HANDLE_DBC, hdbc,retcode);
                    SQLFreeHandle(SQL_HANDLE_DBC, hdbc);
                    hdbc = nil;
               if (henv != nil)
                    eqShowStatementError(SQL_HANDLE_ENV, henv,retcode);
                    SQLFreeHandle(SQL_HANDLE_ENV, henv);
                    henv = nil;
          } else MessageBox(null,_T("Connected."),_T("Success"),MB_OK);
     return retcode;
void eqShowStatementError(SQLSMALLINT chHandleType, SQLHANDLE hHandle,long lErrOrig)
     SQLRETURN          nErr          = SQL_SUCCESS;
     int                    nRecNum = 1;
     SQLTCHAR          szSqlState[6];
     SQLTCHAR          szMsg[SQL_MAX_MESSAGE_LENGTH];
     SQLSMALLINT          nMsgLen;
     SQLINTEGER          nNativeError;
     while ((nErr = SQLGetDiagRec(chHandleType,hHandle,nRecNum,
                                        szSqlState, &nNativeError,
                                        szMsg, sizeof(szMsg), &nMsgLen)) != SQL_NO_DATA)
          szSqlState[5] = 0;
          MessageBox(NULL,(const TCHAR *)szMsg,_T("ODBC Error"),MB_OK);
          ++nRecNum;

Yes, the 9.2.0.2 driver can be downloaded from OTN. I don't believe it will solve your particular problem, but it will help in general. If you don't grab the latest version, you'll probably have to chack the "Force SQL_WCHAR Support" option in the DSN configuration.
From the help file
"The C data type, SQL_C_WCHAR, was added to the ODBC interface to allow applications to specify that an input parameter is encoded as Unicode or to request column data returned as Unicode. The macro SQL_C_TCHAR is useful for applications that need to be built as both Unicode and ANSI. The SQL_C_TCHAR macro compiles as SQL_C_WCHAR for Unicode applications and as SQL_C_CHAR for ANSI applications."
My first thought would be that your application is not being compiled as Unicode. If you substitute SQL_C_WCHAR for SQL_C_TCHAR when you're dealing with NCLOB columns, I suspect you'll have better luck.
More help file
"The SQL data types, SQL_WCHAR, SQL_WVARCHAR, and SQL_WLONGVARCHAR, were added to the ODBC interface to represent columns defined in a table as Unicode. These values are potentially returned from calls to SQLDescribeCol, SQLColAttribute, SQLColumns, and SQLProcedureColumns. In Oracle release 8.1.7.0.0 or 9.0.1.0.0, the Oracle database does not support encoding columns as Unicode. These values would not be returned from the ODBC Drivers for Oracle release 8.1.7.0.0 or for Oracle 9.0.1.0.0 databases.
In Oracle release 9.2.0.0.0, Unicode encoding was supported for SQL column types NCHAR, NVARCHAR2, and NCLOB. In addition, Unicode encoding was also supported for SQL column types CHAR and VARCHAR2 if the character semantics were specified in the column definition.
Starting with release 9.2.0.2.0, the ODBC Driver supports these SQL column types and maps NCHAR to the SQL data type SQL_WCHAR, NVARCHAR2 is mapped to SQL_WVARCHAR, and NCLOB is mapped to SQL_WLONGVARCHAR. The SQL CHAR column is mapped to SQL_WCHAR and the VARCHAR2 column is mapped to SQL_WVARCHAR if the character semantics are specified for the column. While the Force SQL_WCHAR Support option is still available in the 9.2.0.2.0 ODBC Driver, it is no longer required for Unicode support."
Justin

Similar Messages

  • I need help restoring data from my time machine.

    1)  On the time machine, where do I find the TRASH file that is located on the dock in my desktop?  I'd like to restore that to a prior date but can't find it.
    2)   I DID A VERY BAD THING & need help to get back to where I was before.   I wanted to delete files that were taking up lots of space.  My OTHER section  was using 160G.  I downloaded OmniDiskSweep and found that 120G was being used by my virtual machine (I run Quicken in Windows, through VMware).  I started to delete files that were called Snapshots assuming these were the snapshots that the program regularly takes of my files. Apparently they were not. I also deleted the program Windows XP Professional because that was never used.  When I try to open VM or quicken program, it says it is missing a particular snapshot, i.e. Snapshot 11104.  I deleted about 20 of these. I left all the other files that said Windows XP Home Edition.  But now it shows that I only have the Professional Edition, even though that's what I deleted.  I'm trying to restore from Time Machine and it looks like the information is not there - I've tried various different backups and nothing seems to have the information I need.  The earliest back up I have is from 5/7 when I started time machine on a new external 1TB HD.  Would that have the information I need since it's the very first back up?  Please Help.

    I am assuming it's real data because it's taking up storage on my HD.  It falls in the category "other" and the total of this section is 160G. Here is a snapshot of the virtual machine.
    I also took a shot of the VM snapshots & it tells how much space is being taken up by the snapshots.
    I've now changed the number of snapshots taken down to 12 (didn't know I had this option) & I can delete alot of the 21 snapshots that have already been saved.  I have no idea how much of the HD was set aside for the VM because someone else installed it for me 5 years ago.  I've had enough problems with it over the years that I've wanted to switch to Quicken for Mac or find another financial program to use. I've upgraded the VM 2x over the years, but didn't want to spend $100 for Version 5.   I understand the concept of a VM but that's about all.
    I did do the disk cleanup in Windows on the C drive.  I deleted 700 MB of temporary files and then compressed 4G of data down to 2G.  While the cleanup was progressing it said that the C drive was 30.99G and 78% of it was free.  That just doesn't make sense to me.  It recommended a defrag, so I did that also.
    I'm pretty sure it's real data because I recently had to switch from a 320G external HD for TM, to a 1T HD.  One TM backup was over 300G which I found to be excessive because I basically use my computer for mail, some word processing, and my financial data.
    Thanks again for all your help. I really appreciate it.

  • Need Help:Reading Data from RU payroll cluster for table GRREC

    Hi...
    I need help on how to read data from RU cluster table for table GRREC for the employee & run date and get the value from structure PC292 .
    Please let me know about the includes and the import and export statements to be used.
    Thanks in advance,
    RAVI.

    Hi,
    Here goes pseudocode
    Includes:
    include: rpppxd00    ,
                rpppxd10     ,
                rpc2cd09     , 
                rpc2rx02_ce , "if ldb pnp_ce is used else use the same include with out _ce
                rpc2rx29      ,  
                rpc2rx39      ,
                rpppxm00    ,
                rpc2ruu0_ce ,
    Declare:
    DATA : i_rgdir   LIKE pc261        OCCURS 0 WITH HEADER LINE     ,
               i_result  TYPE pay99_result OCCURS 0 WITH HEADER LINE ,
               i_grrec   LIKE  pc292           OCCURS 0 WITH HEADER LINE .
    start-of-selection:
    GET pernr.
    Get the RGDIR VALUE for the current PERNR & selected Molga
    get rgdir data TABLES i_rgdir
                          USING pernr-pernr
                                     p_molga " parameter
    CD-KEY-PERNR = PERNR-PERNR.
    RP-IMP-C2-CU.
    i_rgdir [] = rgdir[].
      LOOP AT i_rgdir WHERE fpbeg  LE  pn-endda
                        AND fpend  GE  pn-begda
                        AND srtza  EQ 'A'
                        AND void   NE   'V'.
      get_result_tabs   TABLES i_result
                                   USING 'RU'    "  US cluster
                                         pernr-pernr
                                         i_rgdir-seqnr
          RX-KEY-PERNR = PERNR-PERNR.
          UNPACK i_RGDIR-SEQNR TO RX-KEY-SEQNO.
          RP-IMP-C2-RU.
      i_grrec[] = i_result-inter-grrec[].
      LOOP AT i_grrec.
      case i_grrec.
      use wage types required here and pass the data to output table.
      endcase.
      endloop.
      endloop
    end-of-selction.

  • Need help pulling data from an outside file into my array.  Please help  =)

    Hi,
    I need help adapting my array to read the interest rates from an outside file. Here is my code and the outside file I wrote. Please help. Oh, the array in question is on line 259, inside of my calculation() method.
    Thanks...
    import javax.swing.*;
    import javax.swing.event.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.text.NumberFormat;
    import java.text.DecimalFormat;
    import java.io.*;
    import javax.swing.JOptionPane;
    public class Workshop5 extends JFrame implements ActionListener
         //declare gui components
         //declare labels
         JPanel contentPane = new JPanel();
         JPanel graphPane = new JPanel();
        JLabel instructionLabel = new JLabel();
        JLabel amountLabel = new JLabel();
         JLabel orLabel = new JLabel();
         JLabel comboBoxLabel = new JLabel();
         JLabel termLabel = new JLabel();
         JLabel rateLabel = new JLabel();
         JLabel calcLabel = new JLabel();
         JLabel paymentLabel = new JLabel();
         JLabel tableLabel = new JLabel();
         //declare font object
         Font labelFont = new Font("Tahoma", Font.PLAIN, 16);
         //declare text fields
         JTextField amountField = new JTextField(20);    
         JTextField termField = new JTextField(20);     
         JTextField rateField = new JTextField(20);
         JTextField paymentField= new JTextField(20);
         //declare combo box for loan selection
         JComboBox comboBox = new JComboBox();
        //declare button group and radio buttons
        ButtonGroup buttonGroup = new ButtonGroup();
        JRadioButton enterRadioButton = new JRadioButton("Enter amount, term, & rate", true);
        JRadioButton selectRadioButton = new JRadioButton("Select a preset term/rate loan", false);
         //declare button objects
         JButton clearButton = new JButton();
        JButton calcButton = new JButton();
        JButton quitButton = new JButton();
         //declare text area for amortization
         JTextArea amortTextArea = new JTextArea();
         JTextArea testTextArea = new JTextArea();
         //declare scroll bar for amortization table
         JScrollPane scrollPane = new JScrollPane(amortTextArea,ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
         public Workshop5()
              instructionLabel.setText("Choose one of the following payment calculation options:");
              instructionLabel.setFont(new Font("Tahoma",Font.PLAIN,16));
              //adds both buttons to button group     
              buttonGroup.add(enterRadioButton);
              buttonGroup.add(selectRadioButton);
              enterRadioButton.setFont(labelFont);
              enterRadioButton.setBackground(Color.WHITE);
              enterRadioButton.setContentAreaFilled(false);
             enterRadioButton.addActionListener(this); //adds action listener to enter radio button
              orLabel.setText("OR");
              orLabel.setFont(new Font("Tahoma",Font.BOLD,18));
              selectRadioButton.setFont(labelFont);
              selectRadioButton.setBackground(Color.WHITE);
              selectRadioButton.setContentAreaFilled(false);
              selectRadioButton.addActionListener(this); //adds action listener to select radio button
              amountLabel.setText("Enter mortgage amount");
              amountLabel.setFont(new Font("Tahoma", Font.PLAIN,16));
              amountField.requestFocusInWindow();
              termLabel.setText("Enter term length in years:");
              termLabel.setFont(new Font("Tahoma", Font.PLAIN,14));
              rateLabel.setText("Enter interest rate:");
             rateLabel.setFont(new Font("Tahoma", Font.PLAIN,14));
                comboBoxLabel.setText("Select a loan:");
             comboBoxLabel.setFont(new Font("Tahoma", Font.PLAIN,14));
             comboBox.setBackground(new Color(255,255,255));
             comboBox.setFont(new Font("Tahoma", Font.PLAIN, 14));
             comboBox.setEnabled(false);
             ComboBox();
              calcLabel.setText("Press Calculate button to determine monthly payment.");
             calcLabel.setFont(new Font("Tahoma", Font.PLAIN, 16));
             calcButton.setText("Calculate");                    
             calcButton.setFont(new Font("Tahoma", Font.BOLD, 14));
             calcButton.addActionListener(this);
                //define monthly payment label
             paymentLabel.setText("Monthly payment:");
             paymentLabel.setFont(new Font("Tahoma", Font.PLAIN, 16));
             //define monthly payment text field
             paymentField.setFont(new Font("Tahoma", Font.BOLD,16));
             paymentField.setBackground(new Color(255,255,255));
             paymentField.setEditable(false); 
              //define clear button
              clearButton.setText("Clear"); 
              clearButton.setFont(new Font("Tahoma", Font.BOLD,14));
              clearButton.addActionListener(this);
              //define quit button
              quitButton.setText("Quit");
              quitButton.setFont(new Font("Tahoma", Font.BOLD,14));
              quitButton.addActionListener(this);         
              tableLabel.setText("Amoritization Table");
              tableLabel.setFont(new Font("Tahoma", Font.BOLD, 16));
              graphPane.setBackground(Color.WHITE);
              //add components to content     
              getContentPane().add(contentPane);
              contentPane.setLayout(null);
              addComponent(contentPane, instructionLabel, 80,10,450,26);
              addComponent(contentPane, enterRadioButton, 30,40,220,30);
              addComponent(contentPane, orLabel, 280,40,100,30);
              addComponent(contentPane, selectRadioButton, 335,40,350,30);
              addComponent(contentPane, amountLabel, 100,80,220,26);
              addComponent(contentPane, amountField, 300,80,150,26);
              addComponent(contentPane, termLabel, 15,125,200,30);
              addComponent(contentPane, termField, 195,125,125,30);
              addComponent(contentPane, rateLabel, 62,160,200,30);
              addComponent(contentPane, rateField, 195,165,125,30);
              addComponent(contentPane, comboBoxLabel, 400,125,200,26);
              addComponent(contentPane, comboBox, 400,155,150,30);
              addComponent(contentPane, calcLabel, 100,200,400,30);
              addComponent(contentPane, calcButton, 250,240,100,30);
              addComponent(contentPane, paymentLabel, 150,285,200,30);
              addComponent(contentPane, paymentField, 300,285,100,30);
              addComponent(contentPane, clearButton, 100,330,100,30);
              addComponent(contentPane, quitButton, 400,330,100,30);
              addComponent(contentPane, tableLabel, 200,370,300,26);
              addComponent(contentPane, scrollPane, 10,400,450,360);
              addComponent(contentPane, graphPane, 475,400,305,360);
              //add window listener to close window when user presses X
              addWindowListener(new WindowAdapter()
                   public void windowClosing(WindowEvent e)    
                        System.exit(0);
             pack();   
         //method to add components
         private void addComponent(Container container, Component c, int x, int y, int width, int height)
              c.setBounds(x, y, width, height);
              container.add(c);
         //action performed method
         public void actionPerformed(ActionEvent event)
              Object source = event.getSource();
              if (source == calcButton)
                   Calculate();
              if (source == clearButton)
                   Clear();
              if (source == quitButton)
                   Exit();
              //defines active area based on user selection of mortgage calculation method
               //if user chooses to enter the mortgage manually, combo box fields are inactive
               if (source == enterRadioButton)
                    comboBox.setEnabled(false);
                    termField.setEnabled(true);
                 termField.setEditable(true);
                 rateField.setEnabled(true);
                 rateField.setEditable(true);
                 amountField.setText("");
                   amountField.requestFocusInWindow();
                   termField.setText("");
                  rateField.setText("");
                  paymentField.setText("");
                  amortTextArea.setText("");
              //if user chooses to select from a preset mortgage, rate and term fields are inactive
              if (source == selectRadioButton)
                   comboBox.setEnabled(true);
                   termField.setEnabled(false);
                   termField.setEditable(false);
                   rateField.setEnabled(false);
                   rateField.setEditable(false);
                   amountField.setText("");
                   amountField.requestFocusInWindow();
                   termField.setText("");
                   rateField.setText("");
                   paymentField.setText("");
                   amortTextArea.setText("");
         }//end of action performed method
         //combo box method
          public void ComboBox()
               String[] LoanArray = {" 7 years at 5.35 %", " 15 years at 5.50 %", " 30 years at 5.75 %"};
               for (int i = 0; i < LoanArray.length; i++)
                    comboBox.addItem(LoanArray);
         }//end combo box method
         //calculation method
         void Calculate()
              //resets fields
              paymentField.setText("");
         amortTextArea.setText("");
              //calculation variables
         NumberFormat currency = NumberFormat.getCurrencyInstance();
              int [] termArray = {7, 15, 30};                               //array of years
                   double [] yearlyInterestArray = {5.35, 5.5, 5.75};           //array of interest
                   int totalMonths = 0;                                    //total months
                   double Loan = 0.0;                               //amount of loan
                   double MonthlyInterest = 0.0;                               //monthly interest rate
                   double Payment = 0.0;                               //calculate payment
                   double monthlyPayment = 0.0;                                   //calculate monthly payment
                   double Interest = 0.0;                                              //variable for Interest Array input
                   int Term = 0;                                              //variable for Term Array input
                   double NewMonthlyInterest = 0.0;                               //new interest amount
                   double NewLoan = 0.0;                               //new loan amount
                   double Reduction = 0.0;                               //principle reduction
                   //validate input
                   try
                        Loan = Double.parseDouble(amountField.getText());
                   catch (NumberFormatException e)
                        JOptionPane.showMessageDialog(null,"Invalid Entry. Please enter valid loan amount.", "Error", JOptionPane.WARNING_MESSAGE);
                   //resets input fields after error message
              amountField.setText("");
              amountField.requestFocusInWindow();
                   //if select button is chosen
              if (selectRadioButton.isSelected())
                   int index = comboBox.getSelectedIndex();
                   Term = termArray[index];
                   Interest = yearlyInterestArray[index];
              //if user chooses to enter mortgage information
              else
                   if (enterRadioButton.isSelected())
                        //validates input
              try
              Term = Integer.parseInt(termField.getText());
              catch (NumberFormatException e)
                   JOptionPane.showMessageDialog(null,"Invalid entry. Please enter valid term length in years.", "Error",JOptionPane.WARNING_MESSAGE);
                   //clears fields after error message
                   termField.setText("");
                   termField.requestFocusInWindow();
              try
                   Interest = Double.parseDouble(rateField.getText());
              catch (NumberFormatException e)
                   JOptionPane.showMessageDialog(null,"Invalid entry. Please enter valid rate (without percent symbol).","Error",JOptionPane.WARNING_MESSAGE);
              //clears fields after error message
              rateField.setText("");
                             rateField.requestFocusInWindow();
                   //perform calculations
                   if (Loan > 0)
                        Loan = Double.parseDouble(amountField.getText());
                        MonthlyInterest = (Interest / 12)/100;
                        totalMonths = Term * 12;
                        monthlyPayment = Loan * MonthlyInterest *(Math.pow((1 + MonthlyInterest), totalMonths)/(Math.pow((1 + MonthlyInterest), totalMonths)-1));
              paymentField.setText("" + currency.format(monthlyPayment));
                        //send information to amortization text area
                   amortTextArea.append("Number\t");
                   amortTextArea.append(" Amount\t");
                   amortTextArea.append("Interest\t");
                   amortTextArea.append("Principle\t");
                   amortTextArea.append("Balance\n");
              NewLoan = Loan;
                        for (int i = 1; i <= totalMonths; i++)
                             NewMonthlyInterest = MonthlyInterest * NewLoan;
                             Reduction = monthlyPayment - NewMonthlyInterest;
                             NewLoan = NewLoan - Reduction;
                             amortTextArea.append(" " + i +"\t");
                             amortTextArea.append(" " + currency.format(monthlyPayment) + "\t");
                             amortTextArea.append(" " + currency.format(NewMonthlyInterest)+ "\t");
                             amortTextArea.append(" " + currency.format(Reduction) + "\t");
                             amortTextArea.append(" " + currency.format(NewLoan) + "\n");
                        //resets fields if loan amount is less than zero
                        if((Loan <= 0 || Term <= 0 || Interest <= 0))
                             paymentField.setText("");
                             amortTextArea.setText("");
         }//end calcualtion method
         //clear method
         void Clear()
              amountField.setText("");
              amountField.requestFocusInWindow();
              termField.setText("");
              rateField.setText("");
              paymentField.setText("");
              amortTextArea.setText("");
         }//end of clear method
         //main method
         public static void main(String args[])
              Workshop5 f = new Workshop5();
              f.setTitle("Carol's Mortgage Calculator");
              f.setBounds(200,100,800,800);
              f.setResizable(false);
              f.setVisible(true);
         }//end of main method
         //exit method
         void Exit()
              System.exit(0);
         }//end of exit method
    }//program end
    My data file is called: "InterestData.dat" and only contains the following text:
    5.35, 5.5, 5.75

    Ok, now I am getting this error message:
    cannot resolve symbol method lenght()
    Please help me out here, this is due tomorrow and I've been killing myself on it...
    attaching program with revised code included, see beginning of calculation method line 250:
    import javax.swing.*;
    import javax.swing.event.*;
    import java.awt.*;
    import java.awt.event.* ;
    import java.text.NumberFormat;
    import java.text.DecimalFormat;
    import java.io.*;
    import javax.swing.JOptionPane;
    public class Workshop5 extends JFrame implements ActionListener
         //declare gui components
        //declare labels
        JPanel contentPane = new JPanel();
         JPanel graphPane = new JPanel();
         JLabel instructionLabel = new JLabel();
            JLabel amountLabel = new JLabel();
        JLabel orLabel = new JLabel();
        JLabel comboBoxLabel = new JLabel();
        JLabel termLabel = new JLabel();
        JLabel rateLabel = new JLabel();
        JLabel calcLabel = new JLabel();
        JLabel paymentLabel = new JLabel();
        JLabel tableLabel = new JLabel();
        //declare font object
        Font labelFont = new Font("Tahoma", Font.PLAIN, 16);
        //declare text fields
        JTextField amountField = new JTextField(20);
        JTextField termField = new JTextField(20);
        JTextField rateField = new JTextField(20);
        JTextField paymentField= new JTextField(20);
        //declare combo box for loan selection
        JComboBox comboBox = new JComboBox();
            //declare button group and radio buttons
            ButtonGroup buttonGroup = new ButtonGroup();
            JRadioButton enterRadioButton = new JRadioButton("Enter amount, term, & rate", true);
            JRadioButton selectRadioButton = new JRadioButton("Select a preset term/rate loan", false);
        //declare button objects
        JButton clearButton = new JButton();
            JButton calcButton = new JButton();
            JButton quitButton = new JButton();
        //declare text area for amortization
        JTextArea amortTextArea = new JTextArea();
        JTextArea testTextArea = new JTextArea();
        //declare scroll bar for amortization table
        JScrollPane scrollPane = new JScrollPane(amortTextArea, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
         public Workshop5()
             instructionLabel.setText("Choose one of the following payment calculation options:");
            instructionLabel.setFont(new Font("Tahoma",Font.PLAIN,16));
            //adds both buttons to button group
            buttonGroup.add(enterRadioButton);
            buttonGroup.add (selectRadioButton);
            enterRadioButton.setFont(labelFont);
            enterRadioButton.setBackground(Color.WHITE);
            enterRadioButton.setContentAreaFilled(false);
            enterRadioButton.addActionListener(this); //adds action listener to enter radio button
            orLabel.setText("OR");
            orLabel.setFont(new Font("Tahoma",Font.BOLD,18));
            selectRadioButton.setFont(labelFont);
            selectRadioButton.setBackground(Color.WHITE);
            selectRadioButton.setContentAreaFilled(false);
            selectRadioButton.addActionListener (this); //adds action listener to select radio button
              amountLabel.setText("Enter mortgage amount");
            amountLabel.setFont(new Font("Tahoma", Font.PLAIN,16));
            amountField.requestFocusInWindow();
            termLabel.setText("Enter term length in years:");
            termLabel.setFont(new Font("Tahoma", Font.PLAIN,14));
            rateLabel.setText("Enter interest rate:");
            rateLabel.setFont(new Font("Tahoma", Font.PLAIN,14));
            comboBoxLabel.setText("Select a loan:");
            comboBoxLabel.setFont(new Font("Tahoma", Font.PLAIN,14));
            comboBox.setBackground(new Color(255,255,255));
            comboBox.setFont(new Font("Tahoma", Font.PLAIN, 14));
            comboBox.setEnabled(false);
            ComboBox();
            calcLabel.setText("Press Calculate button to determine monthly payment.");
            calcLabel.setFont(new Font("Tahoma", Font.PLAIN, 16));
            calcButton.setText("Calculate");
            calcButton.setFont(new Font("Tahoma", Font.BOLD, 14));
            calcButton.setBackground(new Color(202,255,112));
            calcButton.addActionListener(this);
            //define monthly payment label
            paymentLabel.setText("Monthly payment:");
            paymentLabel.setFont(new Font("Tahoma", Font.PLAIN, 16));
            //define monthly payment text field
            paymentField.setFont (new Font("Tahoma", Font.BOLD,16));
            paymentField.setBackground(new Color(255,255,255));
            paymentField.setEditable(false);
              //define clear button
            clearButton.setText("Clear");
            clearButton.setFont(new Font("Tahoma", Font.BOLD,14));
            clearButton.setBackground(new Color(202,255,112));
            clearButton.addActionListener(this);
            //define quit button
            quitButton.setText("Quit");
            quitButton.setFont(new Font("Tahoma", Font.BOLD,14));
            quitButton.setBackground(new Color(202,255,112));
            quitButton.addActionListener(this);
              //define label for amortization table
            tableLabel.setText ("Amoritization Table");
              tableLabel.setFont(new Font("Tahoma", Font.BOLD, 16));
            graphPane.setBackground(Color.WHITE);
            //add components to content
            getContentPane().add(contentPane);
            contentPane.setLayout(null);
              addComponent(contentPane, instructionLabel, 80,10,450,26);
            addComponent(contentPane, enterRadioButton, 30,40,220,30);
            addComponent(contentPane, orLabel, 280,40,100,30);
            addComponent(contentPane, selectRadioButton, 335,40,350,30);
            addComponent(contentPane, amountLabel, 100,80,220,26);
            addComponent(contentPane, amountField, 300,80,150,26);
            addComponent(contentPane, termLabel, 15,125,200,30);
            addComponent(contentPane, termField, 195,125,125,30);
            addComponent(contentPane, rateLabel, 62,160,200,30);
            addComponent(contentPane, rateField, 195,165,125,30);
            addComponent(contentPane, comboBoxLabel, 400,125,200,26);
            addComponent(contentPane, comboBox, 400,155,150,30);
            addComponent(contentPane, calcLabel, 100,200,400,30);
            addComponent(contentPane, calcButton, 250,240,100,30);
            addComponent(contentPane, paymentLabel, 150,285,200,30);
            addComponent(contentPane, paymentField, 300,285,100,30);
            addComponent(contentPane, clearButton, 100,330,100,30);
            addComponent(contentPane, quitButton, 400,330,100,30);
            addComponent(contentPane, tableLabel, 200,370,300,26);
            addComponent(contentPane, scrollPane, 10,400,450,360);
            addComponent(contentPane, graphPane, 475,400,305,360);
            //add window listener to close window when user presses X
            addWindowListener(new WindowAdapter()
                 public void windowClosing(WindowEvent e)
                      System.exit(0);
            pack();
           //method to add components
           private void addComponent(Container container, Component c, int x, int y, int width, int height)
                   c.setBounds(x, y, width, height);
                   container.add(c);
           //action performed method
           public void actionPerformed(ActionEvent event)
                   Object source = event.getSource();
                   if (source == calcButton)
                           Calculate();
                   if (source == clearButton)
                           Clear();
                   if (source == quitButton)
                           Exit();
                   //defines active area based on user selection of mortgage calculation method
                   //if user chooses to enter the mortgage manually, combo box fields are inactive
                   if (source == enterRadioButton)
                           comboBox.setEnabled(false);
                           termField.setEnabled(true);
                   termField.setEditable(true);
                   rateField.setEnabled(true);
                   rateField.setEditable(true);
                   amountField.setText ("");
                           amountField.requestFocusInWindow();
                           termField.setText("");
                       rateField.setText("");
                       paymentField.setText ("");
                       amortTextArea.setText("");
                   //if user chooses to select from a preset mortgage, rate and term fields are inactive
                   if (source == selectRadioButton)
                           comboBox.setEnabled(true);
                           termField.setEnabled(false);
                           termField.setEditable(false);
                           rateField.setEnabled (false);
                           rateField.setEditable(false);
                           amountField.setText("");
                           amountField.requestFocusInWindow();
                           termField.setText ("");
                           rateField.setText("");
                           paymentField.setText("");
                           amortTextArea.setText("");
           }//end of action performed method
           //combo box method
            public void ComboBox()
                   String[] LoanArray = {" 7 years at 5.35 %", " 15 years at 5.50 %", " 30 years at 5.75 %"};
                   for (int i = 0; i < LoanArray.length; i++)
                           comboBox.addItem(LoanArray);
    }//end combo box method
    //calculation method
         void Calculate()
              //resets fields
              paymentField.setText("");
              amortTextArea.setText("");
              //calculation variables
              NumberFormat currency = NumberFormat.getCurrencyInstance();
              //declare input stream object
              InputStream istream;
              //create a file object to refer to the outside file
              File interestData = new File("InterestFile.dat");
              //assign instream to the new file object
              istream = new FileInputStream(interestData);
              try
                   StringBuffer sb = new StringBuffer();
                   BufferedReader in = new BufferedReader(new FileReader(interestData));
                   String line = "";
                   while((line = in.readLine()) != null)
                        sb.append(line);
                   in.close();
                   String fileData = sb.toString();
                   String[] splitData = fileData.split(", ");
                   double [] yearlyInterestArray = new double[splitData.length()];
                   for(int j = 0; j < splitData.length(); j++)
                        yearlyInterestArray[j] = new Double(splitData[j]).doubleValue();
              catch (IOException e)
                   JOptionPane.showMessageDialog(null, "File does not exist." + e.getMessage());
              int [] termArray = {7, 15, 30}; //array of years
              double [] yearlyInterestArray = { 5.35, 5.5, 5.75}; //array of interest
              int totalMonths = 0; //total months
              double Loan = 0.0; //amount of loan
              double MonthlyInterest = 0.0; //monthly interest rate
              double Payment = 0.0; //calculate payment
    double monthlyPayment = 0.0; //calculate monthly payment
    double Interest = 0.0; //variable for Interest Array input
    int Term = 0; //variable for Term Array input
    double NewMonthlyInterest = 0.0; //new interest amount
    double NewLoan = 0.0; //new loan amount
    double Reduction = 0.0; //principle reduction
    //validate input
    try
         Loan = Double.parseDouble(amountField.getText());
    catch (NumberFormatException e)
         JOptionPane.showMessageDialog(null,"Invalid Entry. Please enter valid loan amount.", "Error", JOptionPane.WARNING_MESSAGE);
    //resets input fields after error message
    amountField.setText("");
    amountField.requestFocusInWindow ();
              //if select button is chosen
              if (selectRadioButton.isSelected())
                   int index = comboBox.getSelectedIndex ();
                   Term = termArray[index];
                   Interest = yearlyInterestArray[index];
              //if user chooses to enter mortgage information
              else
                   if (enterRadioButton.isSelected())
              //validates input
              try
                   Term = Integer.parseInt(termField.getText());
    catch (NumberFormatException e)
         JOptionPane.showMessageDialog(null,"Invalid entry. Please enter valid term length in years.", "Error",JOptionPane.WARNING_MESSAGE);
         //clears fields after error message
         termField.setText("");
         termField.requestFocusInWindow();
    try
         Interest = Double.parseDouble(rateField.getText());
    catch (NumberFormatException e)
         JOptionPane.showMessageDialog(null,"Invalid entry. Please enter valid rate (without percent symbol).","Error",JOptionPane.WARNING_MESSAGE);
         //clears fields after error message
         rateField.setText("");
         rateField.requestFocusInWindow();
              //perform calculations
              if (Loan > 0)
                   Loan = Double.parseDouble(amountField.getText ());
                   MonthlyInterest = (Interest / 12)/100;
                   totalMonths = Term * 12;
                   monthlyPayment = Loan * MonthlyInterest *(Math.pow ((1 + MonthlyInterest), totalMonths)/(Math.pow((1 + MonthlyInterest), totalMonths)-1));
    paymentField.setText("" + currency.format(monthlyPayment));
    //send information to amortization text area
    amortTextArea.append("Number\t");
    amortTextArea.append(" Amount\t");
    amortTextArea.append("Interest\t");
    amortTextArea.append("Principle\t");
    amortTextArea.append("Balance\n");
                   NewLoan = Loan;
                   for (int i = 1; i <= totalMonths; i++)
         NewMonthlyInterest = MonthlyInterest * NewLoan;
         Reduction = monthlyPayment - NewMonthlyInterest;
         NewLoan = NewLoan - Reduction;
         amortTextArea.append(" " + i +"\t");
         amortTextArea.append (" " + currency.format(monthlyPayment) + "\t");
         amortTextArea.append(" " + currency.format(NewMonthlyInterest)+ "\t");
         amortTextArea.append(" " + currency.format(Reduction) + "\t");
         amortTextArea.append(" " + currency.format(NewLoan) + "\n");
    //resets fields if loan amount is less than zero
    if((Loan <= 0 || Term <= 0 || Interest <= 0))
         paymentField.setText("");
         amortTextArea.setText("");
         }//end calcualtion method
    //clear method
    void Clear()
    amountField.setText("");
    amountField.requestFocusInWindow();
    termField.setText("");
    rateField.setText("");
    paymentField.setText("");
    amortTextArea.setText("");
    }//end of clear method
    //main method
    public static void main(String args[])
    Workshop5 f = new Workshop5();
    f.setTitle("Carol's Mortgage Calculator");
    f.setBounds(200,100,800,800);
    f.setResizable(false);
    f.setVisible(true);
    }//end of main method
    //exit method
    void Exit()
    System.exit(0);
    }//end of exit method
    }//program end

  • Need Help representing data from a ResultSet

    Hi y'all,
    I have an SQL query which returns information from an Access database with time tabling information (class, day, start time, etc).
    I wish to display the information in table format:
    EG:_________________________________
    _____|MON_|_TUE_|_WED_|_THUR_|_FRI_|
    9.00 | | | | | |
    _____|____|_____|_____|______|_____|
    10.00| | | | | |
    _____|____|_____|_____|______|_____|
    11.00| | | | | |
    _____|____|_____|_____|______|_____|
    I dont know the best way to set about putting the data from the resultset into the table. Will this be very difficult?
    Many thanks in advance,
    John

       this is how i would create a jsp page.
       to output the results in an html table
       you can get the column names from the resultset
       as well to put into the <TH></TH> tags (resultsetmetadata)
    */<html>
    <body>
    <table>
    <tr>
    <th>SUN</TH>
    <th>MON</TH>
    <th>TUE</TH>
    <th>WED</TH>
    <th>THU</TH>
    <th>FRI</TH>
    <TH>SAT</TH>
    </tr>
    </table>
    <%
       int nCols= 5;
       String rws;
       while (rs.next()) {
          int i=0;
          rws+="<tr>"
          while (i++ < nCols) {
             rws="<td>"+ rs.getString(i)+"</td>";
          rws+="</tr>";
    %></body>
    </html>
       this is how i would code a jsp page.
       the connection crap is missing though
    */

  • Need help with data from databases

    Hi,
    I need to search several columns in a table, for ex. the Id column and the Headline column. Of cource the id must be connected to the right headline when I want to do something to the data.
    Now I get a Resultset and I have tried out different ways to get the data out from the Resultset but the result doesn't seems to be right. Can anyone help me, please.
    -Thanks-

    You can iterate on your ResultSet if it contains several
    rows.
    Let's imagine you have defined a class Element containing
    the values you want to use.
    List l = new ArrayList();
    // Calling rs.next() put the cursor on the next row
    // and return false if there is no more row
    while (rs.next()) {
    Element e = new Element(rs.getString(1), rs.getInt(2));
    l.add(e);

  • I need help retreiving data from a stack.

    Ok, i have a few classes:
    public class StackClass
        private  int maxStackSize;    //variable to store the maximum
                                      //stack size
        private  int stackTop;        //variable to point to the top
                                      //of the stack
        private  DataElement[] list;  //array of reference variables
            //default constructor
            //Create an array of size 100 to implement the stack.
            //Postcondition: The variable list contains the base
            //               address of the array, stackTop = 0, and
            //               maxStackSize = 100.
        public StackClass()
            maxStackSize = 100;
            stackTop = 0;         //set stackTop to 0
            list = new DataElement[maxStackSize];   //create the array
        }//end default constructor
            //constructor with a parameter
            //Create an array of size stackSize to implement the stack.
            //Postcondition: The variable list contains the base
            //               address of the array, stackTop = 0, and
            //               maxStackSize = stackSize.
        public StackClass(int stackSize)
            if(stackSize <= 0)
               System.err.println("The size of the array to implement "
                                + "the stack must be positive.");
               System.err.println("Creating an array of size 100.");
               maxStackSize = 100;
            else
               maxStackSize = stackSize;   //set the stack size to
                                           //the value specified by
                                           //the parameter stackSize
            stackTop = 0;    //set stackTop to 0
            list = new DataElement[maxStackSize]; //create the array
        }//end constructor
            //Method to initialize the stack to an empty state.
            //Postcondition: stackTop = 0
        public void initializeStack()
            for(int i = 0; i < stackTop; i++)
                list[i] = null;
            stackTop = 0;
        }//end initializeStack
            //Method to determine whether the stack is empty.
            //Postcondition: Returns true if the stack is empty;
            //               otherwise, returns false.
        public boolean isEmptyStack()
            return (stackTop == 0);
        }//end isEmptyStack
            //Method to determine whether the stack is full.
            //Postcondition: Returns true if the stack is full;
            //               otherwise, returns false.
        public boolean isFullStack()
            return (stackTop == maxStackSize);
        }//end isFullStack
            //Method to add newItem to the stack.
            //Precondition: The stack exists and is not full.
            //Postcondition: The stack is changed and newItem
            //               is added to the top of stack.
            //               If the stack is full, the method throws
            //               StackOverflowException
        public void push(DataElement newItem) throws StackOverflowException
            if(isFullStack())
                throw new StackOverflowException();
            list[stackTop] = newItem.getCopy(); //add newItem at the
                                                //top of the stack
            stackTop++;                         //increment stackTop
        }//end push
            //Method to return the top element of the stack.
            //Precondition: The stack exists and is not empty.
            //Postcondition: If the stack is empty, the method throws
            //               StackUnderflowException; otherwise, a
            //               reference to a copy of the top element
            //               of the stack is returned.
        public DataElement top() throws StackUnderflowException
            if(isEmptyStack())
                throw new StackUnderflowException();
            DataElement temp = list[stackTop - 1].getCopy();
            return temp;
        }//end top
            //Method to remove the top element of the stack.
            //Precondition: The stack exists and is not empty.
            //Postcondition: The stack is changed and the top
            //               element is removed from the stack.
            //               If the stack is empty, the method throws
            //               StackUnderflowException
        public void pop() throws StackUnderflowException
            if(isEmptyStack())
               throw new StackUnderflowException();
            stackTop--;       //decrement stackTop
            list[stackTop] = null;
        }//end pop
            //Method to make a copy of otherStack.
            //This method is used only to implement the methods
            //copyStack and copy constructor
            //Postcondition: A copy of otherStack is created and
            //               assigned to this stack.
        private void copy(StackClass otherStack)
             list = null;
             System.gc();
             maxStackSize = otherStack.maxStackSize;
             stackTop = otherStack.stackTop;
             list = new DataElement[maxStackSize];
                   //copy otherStack into this stack
             for(int i = 0; i < stackTop; i++)
                 list[i] = otherStack.list.getCopy();
    }//end copy
    //copy constructor
    public StackClass(StackClass otherStack)
    copy(otherStack);
    }//end constructor
    //Method to make a copy of otherStack.
    //Postcondition: A copy of otherStack is created and
    // assigned to this stack.
    public void copyStack(StackClass otherStack)
    if(this != otherStack) //avoid self-copy
    copy(otherStack);
    }//end copyStack
    public boolean equalStack(StackClass otherStack) //boolean so that it returns true or false
         if (this.isEmptyStack() == otherStack.isEmptyStack())
              try
                   while(top().compareTo( otherStack.top())==0)
                        pop();
                        otherStack.pop();
                        return false ;
              catch (StackUnderflowException e)
                   return true;
         else
              return false;
         public void reverseStack(StackClass otherStack)
              otherStack.initializeStack();          
              int count = stackTop;
              StackClass stackToCopy = new StackClass(this);
              while (count >= 0)
                   stackToCopy.push(otherStack.top());     
                   otherStack.pop();
                   stackToCopy.pop();
                   count--;
    public abstract class DataElement
        public abstract boolean equals(DataElement otherElement);
          //Method to determine whether two objects contain the
          //same data.
          //Postcondition: Returns true if this object contains the
          //               same data as the object otherElement;
          //               otherwise, it returns false.
        public abstract int compareTo(DataElement otherElement);
          //Method to compare two objects.
          //Postcondition: Returns a value < 0 if this object is
          //                    less than the object otherElement;
          //               Returns 0 if this object is the same as
          //                    the object otherElement.
          //               Returns a value > 0 if this object is
          //                  greater than the object otherElement.
        public abstract void makeCopy(DataElement otherElement);
          //Method to copy otherElement into this object.
          //Postcondition: The data of otherElement is copied into
          //               this object.
        public abstract DataElement getCopy();
          //Method to return a copy of this object.
          //Postcondition: A copy of this object is created and
          //               a reference of the copy is returned.
    public class IntElement extends DataElement
        protected int num;
          //default constructor
        public IntElement()
            num = 0;
          //constructor with a parameter
        public IntElement(int x)
            num = x;
          //copy constructor
        public IntElement(IntElement otherElement)
            num = otherElement.num;
          //Method to set the value of the instance variable num.
          //Postcondition: num = x;
        public void setNum(int x)
            num = x;
          //Method to return the value of the instance variable num.
          //Postcondition: The value of num is returned.
        public int getNum()
            return num;
        public boolean equals(DataElement otherElement)
            IntElement temp = (IntElement) otherElement;
            return (num == temp.num);
        public int compareTo(DataElement otherElement)
            IntElement temp = (IntElement) otherElement;
            return (num - temp.num);
        public void makeCopy(DataElement otherElement)
            IntElement temp = (IntElement) otherElement;
            num = temp.num;
        public DataElement getCopy()
            IntElement temp = new IntElement(num);
            return temp;
        public String toString()
            return String.valueOf(num);
    public class example
         public static void main(String[] args)
              StackClass stack1 = new StackClass();
              stack1.push(new IntElement(1));
              stack1.push(new IntElement(2));
              stack1.push(new IntElement(3));
              //NEED OUTPUT STATEMENTS HERE
    }In the last program, I need to be able to output "3,2,1" which should be easy because 3 is on top and 1 is on bottom. The problem is, I have no idea how to make a proper output statement for an intElement inside a stack.
    Thanks
    -Allen

    in this case, the pop method is simply supposed to
    discard the top dataElement.
    the top method is supposed to return it, without
    discarding it.
    so to get the discard and return effect you are
    describing, you would simply use top then pop.Ok, so you're good to go then (?)
    DataElement d = stack1.top();
    System.out.println("Here's one of the elements: " + d);
    stack1.pop();
    // rinse and repeat until the stack is empty

  • Need help loading data from Excel data file to oracle tables

    i need to load an Excel spreadsheet to Oracle table.
    The spreadsheet contains 20 columns, the first 8 columns contains basic info, but the rest 12 columns contains info like
    1stQtr_08, 2ndQtr_08, 3rdQtr_08, 4thQtr_08
    1stQtr_09, 2ndQtr_09, 3rdQtr_09, 4thQtr_09
    1stQtr_10, 2ndQtr_10, 3rdQtr_10, 4thQtr_10
    So what i need to accomplish is:
    break that one record(with 20 fields) in Excel to 3 records for each fiscal year in the Oracle table, so each record in the database table will look like
    8 basic field + fiscal_year + 1stQtr_08, 2ndQtr_08, 3rdQtr_08, 4thQtr_08
    8 basic field + fiscal_year + 1stQtr_09, 2ndQtr_09, 3rdQtr_09, 4thQtr_09
    8 basic field + fiscal_year + 1stQtr_10, 2ndQtr_10, 3rdQtr_10, 4thQtr_10
    There are about 10000 rows in the data file, so how can i use sqlldr to perform such task? beside sqlldr, any other good suggestions?
    thx

    External Tables is just an Oracle API for sqlloader. If you going to load this data over and over again, External tables would be a good idea, but if it's a one time thing, sqlldir is simpler, unless you just want to learn how to use External Tables.
    I used to run a data warehouse, so I have done, at least similar, to what you are doing in the past.

  • Need Help Pulling Data from Oracle Table (Newby)

    Let me start of by saying I'm very new to Java so the code may be messy/poorly coded (I'm trying!). However, I've come a long way already and the code is almost working (it compiles and returns what I expect in one case). What I'm trying to do is prompt the user to enter a type, then a key. I use that type to determine the SQL statement to use then I use the key as part of the SQL statement.
    If I enter 'custnum' as the type, then a string as my key, it finds the record fine.
    If I any of my other valid types (lname, address or phone) and then enter my key, the result set is empty. I've verified that there are matching records for the type/key I'm entering.
    I've tried stepping it through the debugger and looking at various variables along the way both with the working scenario and the not-working scenario, but I can't find anything. I'm sure it's a simple coding mistake, but I don't really know how to track it down.
    Any ideas on what's going wrong would be greatly appreciated. Thanks!
    //Start code
    import java.sql.*;
    import java.util.Scanner;
    public class AccessCustomerTable
    private static final String DEFAULT_DRIVER = "oracle.jdbc.driver.OracleDriver";
    private static final String DEFAULT_URL = "jdbc:oracle:thin:@hostname.com:1521:orap1";
    private static final String DEFAULT_USERNAME = "username";
    private static final String DEFAULT_PASSWORD = "password";
    //Set the SQL statements
    private static final String SQLCUSTOMER_CUSTNUM =
    "select CUSTNUM,CUST_LNAME,CUST_FNAME,CUST_PHONE,EMAIL,STAT_LVL,HH_NUM " +
    "from EME.CUSTOMER " +
    "where CUSTNUM=?";
    private static final String SQLCUSTOMER_CUST_LNAME =
    "select CUSTNUM,CUST_LNAME,CUST_FNAME,CUST_PHONE,EMAIL,STAT_LVL,HH_NUM " +
    "from EME.CUSTOMER " +
    "where CUST_LNAME=?";
    private static final String SQLCUSTOMER_CUST_PHONE =
    "select CUSTNUM,CUST_LNAME,CUST_FNAME,CUST_PHONE,EMAIL,STAT_LVL,HH_NUM " +
    "from EME.CUSTOMER " +
    "where CUST_PHONE=?";
    private static final String SQLCUSTOMER_EMAIL =
    "select CUSTNUM,CUST_LNAME,CUST_FNAME,CUST_PHONE,EMAIL,STAT_LVL,HH_NUM " +
    "from EME.CUSTOMER " +
    "where EMAIL=?";
    private static final String SQLDETAIL =
    "select TRANS_DATE,STORENUM,TERMINAL,TRANSID,OPERATOR,SALES_TOT," +
    "AMOUNT_SPENT,AUTO_CPNS,PTS_EARNED,PTS_REDEEMED,RDMT_CPNS,ADD_CPNS," +
    "USED_CPNS,OFFLINE_ALT_ID,RECON_IND " +
    "from EME.CUSTOMERDETAIL " +
    "where CUSTNUM=?";
    private static final String SQLHOUSEHOLD =
    "select PGM_PTS,PERIOD_PTS,PGM_RDM,PERIOD_RDM,SALES_TOT,AUTO_CPNS," +
    "CARD_UCNT,MESSAGE,DISC_GRP,PT_MULTP,USERFEAT1,USERFEAT2,USERFEAT3,TARG_CPNS " +
    "from EME.HOUSEHOLD " +
    "where HH_NUM=?";
    public static void main(String[] args)
    Connection conn = null;
    PreparedStatement stmt = null;
    ResultSet rset = null;
    //declare all variables
    String custNum = "";
    String custLNm = "";
    String transDt = "";
    String storeNum = "";
    String pgmPtsEarned = "";
    String periodPtsEarned = "";
    try {
    //********** Get Customer Data **********
    householdNum = "";
    Class.forName(DEFAULT_DRIVER);
    conn = DriverManager.getConnection(DEFAULT_URL,DEFAULT_USERNAME,DEFAULT_PASSWORD);
    String lookupType = getUserInput("Lookup Type");
    if (lookupType.toUpperCase().equals("CUSTNUM"))
    stmt=conn.prepareStatement(SQLCUSTOMER_CUSTNUM);
    else if (lookupType.toUpperCase().equals("LNAME"))
    stmt=conn.prepareStatement(SQLCUSTOMER_CUST_LNAME);
    else if (lookupType.toUpperCase().equals("PHONE"))
    stmt=conn.prepareStatement(SQLCUSTOMER_CUST_PHONE);
    else if (lookupType.toUpperCase().equals("ADDRESS"))
    stmt=conn.prepareStatement(SQLCUSTOMER_EMAIL);
    else
    //stop execution with message
    System.out.println("Invalid lookup type entered. Process stopping");
    System.exit(0);
    String lookupKey = getUserInput("Lookup Key");
    System.out.println("Lookup Key is " + lookupKey);
    stmt.setString(1,lookupKey);
    rset = stmt.executeQuery();
    //what if rset returns no records?
    boolean empty=true;
    while (rset.next())
    empty=false;
    custNum = rset.getString(1);
    custLNm = rset.getString(2);
    if (empty)
    System.out.println("No records found for " + lookupKey);
    System.exit(0);
    //********** Get Detail Data **********
    stmt=conn.prepareStatement(SQLDETAIL);
    //stmt.setString(1,customerId);
    stmt.setString(1,custNum);
    rset = stmt.executeQuery();
    empty = true;
    while (rset.next())
    empty = false;
    transDt = rset.getString(1);
    storeNum = rset.getString(2);
    if (empty)
    System.out.println("No detail records found for customer # " + custNum);
    System.exit(0);
    //********** Get Household Data **********
    stmt=conn.prepareStatement(SQLHOUSEHOLD);
    stmt.setString(1,householdNum);
    rset = stmt.executeQuery();
    empty = true;
    while (rset.next())
    empty = false;
    pgmPtsEarned = rset.getString(1);
    periodPtsEarned = rset.getString(2);
    if (empty)
    System.out.println("No household records found for " + householdNum);
    System.exit(0);
    catch(Exception x)
    System.out.println(x.getMessage());
    x.printStackTrace();
    finally
    close(rset);
    close(stmt);
    close(conn);
    private static void close(Connection conn)
    try
    if (conn != null)
    conn.close();
    catch (SQLException e)
    e.printStackTrace();
    private static void close(Statement stmt)
    try
    if (stmt != null)
    stmt.close();
    catch (SQLException e)
    e.printStackTrace();
    private static void close(ResultSet rset)
    try
    if (rset != null)
    rset.close();
    catch (SQLException e)
    e.printStackTrace();
    public static String getUserInput(String getVal)
    Scanner sc = new Scanner(System.in);
    //for now, I'll be expecting "CustNum", "LName", "Phone", "Address"
    System.out.println("Enter " + getVal + ": ");
    String returnStr = sc.nextLine();
    return (String) returnStr;
    }

    You're new to Java, so you can be forgiven. You actually tried to do some good things, like close resources. Good for you.
    Do yourself a favor and start trying to think in terms of objects.
    Let's call that class CustomerTableGateway.
    Let's write separate methods for each kind of SQL statement you have.
    Get the logic out of the main method. It's almost useless there.
    There's a computer science principle called DRY - Don't Repeat Yourself. When you see code being repeated, see if you can find a way to rewrite it so you only do it once.
    I'd recommend that you start with a Customer class. Figure out how to map a row from your CUST table into the Customer object. Have an interface that would look like this:
    public interface CustomerDao
        Customer findById(String id);
        List<Customer> findByLastName(String lastName);
        List<Customer> findByName(String firstName, String lastName);
        List<Customer> findByEmail(String email);
        List<Customer> findByPhone(String phone);
    }Have another interface called RowMapper:
    public interface RowMapper
        Object map(ResultSet rs);
    }An implementation for one of those methods might look like this:
    public Customer findById(String id)
         Customer customer = null;
         PreparedStatement stmt = null;
         ResultSet rs = null;
         try
             stmt = this.connection.prepareStatement(FIND_CUSTOMER_BY_ID);
             stmt.setString(1, id);
             rs = stmt.executeQuery();
             while (rs.next())
                 customer = (Customer)this.customerMapper.map(rs);
        catch (SQLException e)
            e.printStackTrace();
        finally
            DatabaseUtils.close(rs);      // move those nice close methods into a utility class so you can reuse them.
            DatabaseUtils.close(stmt);
        return customer;
    }You did a pretty good job. Just go further.
    %

  • Need help recovering data from an Xsan volume

    Ok, let me preface this by saying that I've never used Xsan, so I'm not sure if I'm using the terminology correctly. Feel free to correct me or point me in the right direction so that I may provide better clarification.
    I've got a new client who has  about 5 tb of data locked up in a Netgear ReadyNAS that was set up as an Xsan device on a Mac Pro Server running Lion Server 10.7.4. This was set up by a previous IT services company, and we were preparing to move all of their data to a regular RAID NAS device (there is no use for an Xsan in this office environment) and initiate backup solutions. However, several days ago, the server's boot volume crashed fatally and could not be recovered. There was no backup of the boot volume, so we had to start again from scratch. Since reinstalling Lion Server on the Mac Pro, we have been unable to retrieve the data off of the Netgear ReadyNAS.
    There is no backup of the data on the drive, so we're treating this with kid-golves as far as our approach. So far we've tired connectng to the NAS, but are only seeing a couple of shares that don't appear to hold any data. We've been on the phone with Apple's Enterprise Support Group, and been escalated up to the point of having to pay for higher-end supporty. At that point, we phoned Netgear Support to see what they could offer. They're kindly looking into it over the weekend by logging in remotely, but I'm here to ask if there's anyone here who might have experience with a smilar siuation.
    I've been really hesitant to try and connect to the drive with Xsan Admin, as I want to ensure that nothing gets deleted. Does anyone have a suggestion as to something we might try to get at this data? It seems like it would be a simple matter of connecting to the drive, but that's proving to not be the case.

    I read this and began to shake.  You should track down the solution provider and choke them.
    I hate to be the one to tell you, but based on your post, the data is likely lost forever and this is for many reasons. 
    First, you do not describe the presence of a meta data backup.  This is mistake number 1 of whoever set this solution up.  Deploying an Xsan with a single controller is foolish at best, negligent at worst.  Without it, you have no replication of the volume config information.  Are there SAN clients in this scendario or was there just the controller and folders reshared over file services?
    Next, you mention the boot volume failed with no backup.  Based on this description, it sounds like the boot volume was not a mirror boot so all data was on one platter.  The failure of that platter means the failure of everything.  Your only recourse here is to send the drive out to a drive recovery service or attempt a controller board swap (fingers crossed it is just the controller that failed).  With some luck they can recover enough of the drive to allow you to sticth this together.  This is mistake number 2.
    Next, the files that you REALLY need, /Library/FileSystems/Xsan/*, were never backed up.  With the loss of the boot volume, these files are now not available.  If the Xsan config files were present you could, in theory, stitch together a new controller and resurrect that volume.
    And finally, you do not describe a backup solution for the San volume.  Cry....
    I am sorry for your loss.  If there are more details or the conditions are better than you describe, reply.  Otherwise, bite the bullet and get that drive out to a data recovery service and pray.

  • Need Help transfering data from phone to laptop

     I  have a 4G Samsung that I no longer use, but I still have pictures and music on it that I would like to transfer to my laptop. How can I do that? I bought a ONN Micro USB Sync and Charge Cable to do exactly that. Each time I plug it into the
    phone and laptop, all it does is charge the phone. How do I transfer my pictures and music so I can get rid of the phone? Thank You very much for the help, if its at all possible.  Or, if the cord I have won't work, can someone tell me what I need to
    do to get my pictures & music off the phone? Model #SCH-I405

    You can post your question  here : http://forums.androidcentral.com/samsung-android-phones/
    Arnav Sharma | http://arnavsharma.net/ Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading
    the thread.

  • I need help moving data from my iPod to my computer.

    Is there a way I can take all the music and movies and pictures from my ipod and transfer them onto my computer. Mainly I just want my pictures back I never backed them up on my laptop and that got destroyed while my husband was deployed in iraq a few years back. Im not sure how to work everything I always gave my ipod to him to have him upload everything on it. I just bought a Macbook and I am still learning how it works. Is it even possible to take stuff from my ipod and save it to my computer now?

    First of all, when connecting your iPod to your computer, be sure to click "NO" if you recieve a message like this: "This iPod is linked to another computer. Would you like to replace the content?"
    Then, onto the iPod-to-computer transfer:
    There are a few different methods with transferring iPod songs to your computer.
    These include:
    --- Manually transfer your iPod songs to iTunes. See MacMuse's posting here: iPod songs to computer (MacMuse post)
    --- Add your iPod's folder into the iTunes library (via iTunes). See Jeff Bryan's post here: Using iTunes settings to transfer iPod songs to iTunes
    --- Use a third-party program to get the transferring done. For a Windows computer, CopyPod should work good. Also, you can try out YamiPod.
    I hope that helps you.
    -Kylene

  • SELECT data from two databases

    I have two databases that I need to select data from in a
    single SELECT. Using DWs Advanced window for creating the select I
    don't see any way to select more than 1 Connection. Both databases
    have unique user and passwords but reside on the same server. Any
    idea how I can write a single SELECT to get data from both dbs. I
    assumed it would be similar to selecting data from multiple tables
    within the same db but the connection part is stumping me. Any
    ideas would be greatly appreciated.

    TouchstonePress wrote:
    > Page 48, Developing a Web Database Application . . .
    speaks about making a
    > database with two related TABLES each with the same
    PRIMARY KEY column with
    > which to identify a customer using their unique number.
    That's the basic technique for joining two tables in the same
    database.
    The original poster has tables in different databases that
    have
    different user accounts and passwords.
    Although it's possible to join two databases, you cannot do
    it unless
    you have one user account with the same privileges on both
    databases.
    David Powers, Adobe Community Expert
    Author, "The Essential Guide to Dreamweaver CS3" (friends of
    ED)
    Author, "PHP Solutions" (friends of ED)
    http://foundationphp.com/

  • Selecting datas from tables where tbale name is store in a row

    Hi
    I need to select datas from several different table (QE01, QE02, QE06, QEXXetc.).
    The code of the tables I need to select from is store in another table.
    Here's an example:
    In the table JOURNAL, I have several entries:
    01
    06
    21
    31
    These are the codes of the tables I need to select datas from:
    QE01
    QE06
    QE21
    QE31
    I can't use variables in here, how could that be done ?

    Hi,
    This should not be a question on how to query data, but rather on how to store them.
    You did not mention any version, but I suggest you read about partitioning,
    http://download.oracle.com/docs/cd/E11882_01/server.112/e25789/schemaob.htm#CNCPT112
    Could be that especially exchange partition is interesting.
    My guess is that these tables are created on the fly as part of data loads?
    If so, complete that ETL process by exchanging the just loaded data into a partioned table. And your problem of what to query has disappeared.
    Regards
    Peter

  • Need to Get Data From Siebel On Demand ( I am new to Siebel Please Help)

    Hi All,
    I have a project in which i need to get data from Siebel On Demand and Automate this process.
    I have downloaded the Custom WSDL file and the Schema file from Oracle Siebel On Demand. I am using IDE WSAD and when i import these files into WSAD i am getting an error stating the schema definitions are wrong. Can anyone help me.....
    I need to complete it asap....
    Edited by: user491578 on Nov 11, 2008 6:50 PM

    You should probably ask Advantech. This question really has nothing to do with LabVIEW SE or NI-ELVIS. You could try posting to the LabVIEW board but there have only ever been two posts regarding 'advantech 4716'.

Maybe you are looking for