JDBC manipulating data with JTable

I have this code where i want to update the status of a student wher ethe cells are checked. Im just not sure what is the best way to do it. How do I go by grabbing the data from the table and updating the database? Here is the code. Certain parts are commented out for testing purposes.public void make_tableCY(){  
          /*try {
               // Create a resultset to search for course number entered in the course_num textfield
               PreparedStatement psSearchCourse= conn.prepareStatement("Select certification_date, expiration_date from registration where course_num= ?");
               //psSearchCourse.setString(1, (String) CY.jcbCoursenum.getSelectedItem());
               CY.rsSearchCourse = psSearchCourse.executeQuery();
               CY.rsSearchCourse.next();
               //CY.jtfCertDate.setText(CY.rsSearchCourse.getString(1));
               CY.rsSearchCourse.close();
               psSearchCourse.close(); 
          catch(SQLException sqlex)
               JOptionPane.showMessageDialog(null,"Please enter a valid course number");           
          try
               //  Read data from a table
               //PreparedStatement ps =conn.prepareStatement("SELECT Registration.STUDENT_ID  ,  Students.LNAME , Students.FNAME, Registration.Course_Stat_desc  FROM Registration, Students WHERE  Registration.Student_ID = Students.Student_id AND registration.course_num=?");
               PreparedStatement ps =conn.prepareStatement("SELECT * from students");
               //ps.setString(1, (String) CY.jcbCoursenum.getSelectedItem());
               ResultSet rs = ps.executeQuery();
               ResultSetMetaData md = rs.getMetaData();
               int columns = md.getColumnCount();
               //  Get column names
               for (int i = 1; i <= columns; i++)
                    CY.columnNames.addElement( md.getColumnName(i) );
               CY.columnNames.addElement("Pass");
               while (rs.next())
                    Vector row = new Vector(columns);
                    for (int i = 1; i <= columns; i++)
                         row.addElement( rs.getObject(i) );
                    row.addElement(Boolean.TRUE);
                    CY.data.addElement( row);
               rs.close();
               ps.close();
          catch(SQLException sqlex)
               JOptionPane.showMessageDialog(null,"in the certify table");
          CY.table = new JTable( CY.data, CY.columnNames){
               public Class getColumnClass(int column)
                    return getValueAt(0, column).getClass();
          CY.table.setSelectionBackground(Color.CYAN);
          /*TableColumn includeColumn = CY.table.getColumnModel().getColumn(0);
          includeColumn.setCellEditor(new DefaultCellEditor(new JCheckBox()));*/
          //adds table to scrollpane
          CY.scrollPane = new JScrollPane( CY.table );
          CY.scrollPane.setBackground(Color.CYAN);
          CY.background.add(CY.scrollPane );
          CY.scrollPane.setBounds (20, 160, 585, 155);
          //CY.jbtSearchCourse.setEnabled(false); 
          CY.jbtCertify.setEnabled(true);
     }

Looking for something like this
create or replace type objIncome as object(incomeType varchar2(50), income number(10,2))
create or replace type tblIncome as table of objIncome
declare
  lIncomeTbl tblIncome := tblIncome();
begin
  lIncomeTbl.extend;
  lIncomeTbl(1) := objIncome('cash','500');
  lIncomeTbl.extend;
  lIncomeTbl(2) := objIncome('Service','100');
  lIncomeTbl.extend;
  lIncomeTbl(3) := objIncome('cash','100');
  lIncomeTbl.extend;
  lIncomeTbl(4) := objIncome('penalty','50');
  lIncomeTbl.extend;
  lIncomeTbl(5) := objIncome('Service','200');
  lIncomeTbl.extend;
  lIncomeTbl(6) := objIncome('penalty','80');
  for i in (select incometype, sum(income) income
              from table(lIncomeTbl)
             group by incometype)
  loop
    dbms_output.put_line('Income Type: ' || i.incometype ||' Income: ' || i.income);
  end loop;
end;
/

Similar Messages

  • Help please with Jtable

    HI
    I'm having problems
    I have a frame that has a textField, button, label.
    The button is used to diplay the Jtable which has the resultSet.
    My query is:
    String query = "SELECT personID, firstName, surname FROM Person where firstName = '" + jTxtTest.getText() + "'";
    If I enter Gita in the textField and press the button it should display the personID, firstName, surname where firtsname = Gita
    in the Jtable and also display Gita in the label.
    But it only display Gita in the Label but noting in the Jtable.
    What am i doing wrong?????
    public class Frame1 extends JFrame {
    JPanel contentPane;
    BorderLayout borderLayout1 = new BorderLayout();;
              String driver="sun.jdbc.odbc.JdbcOdbcDriver";
              String url="jdbc:odbc:myDatabase";
              String tempname = "";
              int tempcnt;
              JTabbedPane tabbedPane = new JTabbedPane();
              Object[] data = new Object[20];
              DefaultTableModel defaulttablemodel = new DefaultTableModel();
              JTable jtable = new JTable(defaulttablemodel);
    JPanel p1 = new JPanel();
    JTabbedPane jTabbedPane1 = new JTabbedPane();
    JPanel jPanel1 = new JPanel();
    JTextField jTxtTest = new JTextField();
    JButton jButton1 = new JButton();
    JLabel jLabel1 = new JLabel();
    /**Construct the frame*/
    public Frame1() {
    enableEvents(AWTEvent.WINDOW_EVENT_MASK);
    try {
    jbInit();
    catch(Exception e) {
    e.printStackTrace();
    /**Component initialization*/
    private void jbInit() throws Exception {
    setup();
    contentPane = (JPanel) this.getContentPane();
    this.setSize(new Dimension(554, 532));
    this.setTitle("Frame Title");
    jPanel1.setLayout(null);
    jTxtTest.setBounds(new Rectangle(53, 20, 208, 33));
    jButton1.setText("jButton1");
    jButton1.setBounds(new Rectangle(314, 19, 130, 36));
    jButton1.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(ActionEvent e) {
    jButton1_actionPerformed(e);
    jLabel1.setBounds(new Rectangle(462, 23, 82, 20));
    contentPane.add(jTabbedPane1, BorderLayout.CENTER);
    jTabbedPane1.add(jPanel1, "jPanel1");
    jPanel1.add(jTxtTest, null);
    jPanel1.add(jButton1, null);
    jPanel1.add(jLabel1, null);
    void setup()
                   setupMenuBar();
                   showpane1();
                   //contentPane.add(tabbedPane, BorderLayout.CENTER);
              //------------------------------------------------------------ End setup -----------------
              //============================================================ Start setupMenuBar ========
              void setupMenuBar()
                   MenuBar menuBar = new MenuBar();
                   Menu fileMenu = new Menu("File");
                             MenuItem fileExit = new MenuItem("Exit");
                                  fileExit.addActionListener(new MenuItemHandler());
                                  fileMenu.add(fileExit);
    MenuItem filePrev = new MenuItem("Preview");
                                  filePrev.addActionListener(new MenuItemHandler());
                                  fileMenu.add(filePrev);
                             menuBar.add(fileMenu);
                   setMenuBar(menuBar);
              //------------------------------------------------------------ End setupMenuBar-----------
              //============================================================ Start showpane1 =========
              void showpane1() // REPORTS TAB WITH JTABLE
                   p1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),"Student Reports 1"));
    p1.setBounds(new Rectangle(28, 70, 513, 429));
    try
                             Class.forName(driver);
                             Connection connection=DriverManager.getConnection(url);
                             Statement statement = connection.createStatement();
                             String query = "SELECT personID, firstName, surname FROM Person where firstName = '" + jTxtTest.getText() + "'";
                             ResultSet rs = statement.executeQuery(query);
    if (rs == null)
    System.out.println("cannot execute query");
                             ResultSetMetaData rmeta = rs.getMetaData();
                             int numColumns=rmeta.getColumnCount();
    for(int i=1;i<=numColumns;++i)
                                  if(i<=numColumns)
                                       defaulttablemodel.addColumn(rmeta.getColumnName(i));
                             while(rs.next())
                                  for(int i=1;i<=numColumns;++i)
                                       if(i<=numColumns)
                                            tempname = rs.getString(i);
                                            tempcnt=i-1;
                                            data[tempcnt] = tempname;
                                  defaulttablemodel.addRow(data);
                   catch(Exception ex)
         p1.add(new JScrollPane(jtable));
              //------------------------------------------------------------ End showpane1 ------------
              //=========================================================== START MenuItemHandler ======
              class MenuItemHandler implements ActionListener
                   public void actionPerformed(ActionEvent ev)
                        String s=ev.getActionCommand();
                        if(s=="Exit")
                        System.exit(0);
    else if (s=="Preview")
    /**Overridden so we can exit when window is closed*/
    protected void processWindowEvent(WindowEvent e) {
    super.processWindowEvent(e);
    if (e.getID() == WindowEvent.WINDOW_CLOSING) {
    System.exit(0);
    void jButton1_actionPerformed(ActionEvent e) {
    jLabel1.setText(jTxtTest.getText());
    jPanel1.add(p1);
    contentPane.repaint();
    }

    Hi,
    Seems u r new to progrmming.Well u used Jbuilder to write.U wrote good debug statments but forgot to write deubg statment or printstacktrace in excpetions.
    ok here is answer for ur problem.
    import javax.swing.*;
    import javax.swing.table.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.sql.*;
    public class Frame1 extends JFrame {
    JPanel contentPane;
    BorderLayout borderLayout1 = new BorderLayout();;
    String driver="org.gjt.mm.mysql.Driver";
    String url="jdbc:mysql://thienpo-app.thienpo.com/jps";
    String user="";
    String pass="";
    String tempname = "";
    int tempcnt;
    boolean firstTime=false;
    JTabbedPane tabbedPane = new JTabbedPane();
    Object[] data = new Object[20];
    DefaultTableModel defaulttablemodel = new DefaultTableModel();
    JTable jtable = new JTable(defaulttablemodel);
    JPanel p1 = new JPanel();
    JTabbedPane jTabbedPane1 = new JTabbedPane();
    JPanel jPanel1 = new JPanel();
    JTextField jTxtTest = new JTextField();
    JButton jButton1 = new JButton();
    JLabel jLabel1 = new JLabel();
    /**Construct the frame*/
    public Frame1() {
    enableEvents(AWTEvent.WINDOW_EVENT_MASK);
    try {
    jbInit();
    catch(Exception e) {
    e.printStackTrace();
    /**Component initialization*/
    private void jbInit() throws Exception {
    setupMenuBar();
    contentPane = (JPanel) this.getContentPane();
    this.setSize(new Dimension(554, 532));
    this.setTitle("Frame Title");
    jPanel1.setLayout(null);
    jTxtTest.setBounds(new Rectangle(53, 20, 208, 33));
    jButton1.setText("jButton1");
    jButton1.setBounds(new Rectangle(314, 19, 130, 36));
    jButton1.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(ActionEvent e) {
    jButton1_actionPerformed(e);
    jLabel1.setBounds(new Rectangle(462, 23, 82, 20));
    contentPane.add(jTabbedPane1, BorderLayout.CENTER);
    jTabbedPane1.add(jPanel1, "jPanel1");
    jPanel1.add(jTxtTest, null);
    jPanel1.add(jButton1, null);
    jPanel1.add(jLabel1, null);
    this.setVisible(true);
    //------------------------------------------------------------ End setup -----------------
    //============================================================ Start setupMenuBar ========
    void setupMenuBar()
    MenuBar menuBar = new MenuBar();
    Menu fileMenu = new Menu("File");
    MenuItem fileExit = new MenuItem("Exit");
    fileExit.addActionListener(new MenuItemHandler());
    fileMenu.add(fileExit);
    MenuItem filePrev = new MenuItem("Preview");
    filePrev.addActionListener(new MenuItemHandler());
    fileMenu.add(filePrev);
    menuBar.add(fileMenu);
    setMenuBar(menuBar);
    //------------------------------------------------------------ End setupMenuBar-----------
    //============================================================ Start showpane1 =========
    void showpane1() // REPORTS TAB WITH JTABLE
    p1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),"Student Reports 1"));
    p1.setBounds(new Rectangle(28, 70, 513, 429));
    try
    Class.forName(driver);
    Connection connection=DriverManager.getConnection(url,user,pass);
    Statement statement = connection.createStatement();
    String query = "SELECT personID, firstName, surname FROM Person where firstName = '" + jTxtTest.getText() + "'";
    System.out.println(" query"+query);
    ResultSet rs = statement.executeQuery(query);
    if (rs == null)
    System.out.println("cannot execute query");
    System.out.println(" query"+query);
    ResultSetMetaData rmeta = rs.getMetaData();
    int numColumns=rmeta.getColumnCount();
    if( !firstTime){
    for(int i=1;i<=numColumns;++i)
    if(i<=numColumns )
    defaulttablemodel.addColumn(rmeta.getColumnName(i));
    firstTime=true;
    while(rs.next())
    for(int i=1;i<=numColumns;++i)
    if(i<=numColumns)
    tempname = rs.getString(i);
    tempcnt=i-1;
    data[tempcnt] = tempname;
    defaulttablemodel.addRow(data);
    catch(Exception ex)
    System.out.println("***********************"+ex);
    p1.add(new JScrollPane(jtable));
    public static void main(String[] args){
         new Frame1();
    //------------------------------------------------------------ End showpane1 ------------
    //=========================================================== START MenuItemHandler ======
    class MenuItemHandler implements ActionListener
    public void actionPerformed(ActionEvent ev)
    String s=ev.getActionCommand();
    if(s=="Exit")
    System.exit(0);
    else if (s=="Preview")
    /**Overridden so we can exit when window is closed*/
    protected void processWindowEvent(WindowEvent e) {
    super.processWindowEvent(e);
    if (e.getID() == WindowEvent.WINDOW_CLOSING) {
    System.exit(0);
    void jButton1_actionPerformed(ActionEvent e) {
    jLabel1.setText(jTxtTest.getText());
    showpane1();
    jPanel1.add(p1);
    contentPane.repaint();
    sreeni,
    [email protected]

  • Couldn't show sql data in jtable, please help

    Dear All,
    I'm trying to display the data from database in a jtable by following the jtable demo example in Java Tutorials Sample Code; but, I couldn't output the data to the jtable. The following code is what I've done so far. Can anybody please point out a direction for showing the data in jtable? Thanks a lot in advance.
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    import java.util.ArrayList;
    public class Patient {
    static String szJdbcURL = "jdbc:oracle:thin:@129.78.110.188:1521:MyDB";                
    static String szUser = "...";                
    static String szPasswd = "...";                
    static String szModelName = "...";
    static Oracle oracle = new Oracle(szJdbcURL, szUser, szPasswd);
    public void findMedication() throws SQLException{
      Statement stmt1 = null;
      try {
             stmt1=oracle.getConnection().createStatement();             
              String res1=null;
              String res2=null;                
         String sqlQuery="Select * From PatientTable ";
            ResultSet rs= stmt1.executeQuery(sqlQuery);
       if (!rs.isBeforeFirst())
             {System.out.println("OOPS! data not found.");
              System.out.println(); }
       else {
        while (rs.next()) {
       ArrayList<Medication> medList = new ArrayList<Medication>();
       res1=rs.getString("patientName");
       res2=rs.getString("medication");
       Medication med=new Medication (res1, res2);
       medList.add(med);
       System.out.println();
       finally {stmt1.close();}
    import java.util.ArrayList;
    public class Medication {
        String ptName;
        String ptMedication;
    public Medication(String ptName, String ptMedication){
      this.ptName=ptName;
      this.ptMedication=ptMedication;
    public String getPtName() {
      return ptName;
    public void setPtName(String ptName) {
      this.ptName = ptName;
    public String getPtMedication() {
      return ptMedication;
    public void setPtMedication(String ptMedication) {
      this.ptMedication = ptMedication;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.table.AbstractTableModel;
    import java.awt.Dimension;
    import java.awt.GridLayout;
    import java.util.ArrayList;
    public class TableDemo extends JPanel {
      private boolean DEBUG = false;
    public TableDemo () {
      super(new GridLayout(1,0));
      ArrayList<Medication> medList = new ArrayList<Medication>();
      //how to add the data to the ArrayList here?
            JTable table = new JTable(new MyTableModel(medList));
            table.setPreferredScrollableViewportSize(new Dimension(500, 70));
            table.setFillsViewportHeight(true);
            //Create the scroll pane and add the table to it.
            JScrollPane scrollPane = new JScrollPane(table);
            //Add the scroll pane to this panel.
            add(scrollPane);
      class MyTableModel extends AbstractTableModel {
         private String[] columnNames = new String []{"Patient Name", "Medication"};
         ArrayList<Medication> medList = null;
        public MyTableModel (ArrayList<Medication> medList){
         this.medList=medList;
           public int getColumnCount() {  
         return columnNames.length;
       public int getRowCount() {
        return medList.size();
       public String getColumnName(int columnIndex) {
            return columnNames[columnIndex];
    public Object getValueAt(int rowIndex, int columnIndex) {
      Medication object = medList.get(rowIndex);
            switch (columnIndex) {
            case 0:
                 return object.getPtName();
            case 1:
                 return object.getPtMedication();   
            default:
                 return "unknown";
    @SuppressWarnings("unchecked")
    public Class getColumnClass(int c) {
            return getValueAt(0, c).getClass();
         private static void createAndShowGUI() {
             JFrame frame = new JFrame("TableDemo");
             frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
             //Create and set up the content pane.
             TableDemo newContentPane = new TableDemo();
             newContentPane.setOpaque(true); //content panes must be opaque
             frame.setContentPane(newContentPane);
             //Display the window.
             frame.pack();
             frame.setVisible(true);
         public static void main(String[] args) {
             javax.swing.SwingUtilities.invokeLater(new Runnable() {
                 public void run() {
                     createAndShowGUI();

    This line will create an ArrayList which will be used to store the output data of the sql query with the type is Medication class
    NO! Read what TPD ask again carefully -
    Please explain (as explicit as you can) what these two lines do.
    Did you notice that TWO in there?
    Did you notice that your reply said 'This line' when it should have said 'These TWO lines .'?
    You are creating a new ArrayList EVERY TIME thru the loop; you are NOT creating ONE ArrayList and adding things to it.
    The problem is how to show the ArrayList in the jtable defined in another class.
    And the answer is: use one of the THOUSANDS of examples on the internet.
    See the trail 'How to Use Tables' in The Java Tutorials
    http://docs.oracle.com/javase/tutorial/uiswing/components/table.html
    Read the trail - try the example. You learn by doing and using code that already works.

  • Mouselistner is not working with jtable in the browser

    Hi
    I am having a problem with jTable.
    I added a mouselistener to table header to sort table but when i run that applet from my netbean ide it works fine but when i run that applet in my browser it doesn't work, i have tested, its not even generate mouseclick event .Please help me guys.
    I call this function after calling initComponents() method of JApplet.
    public void setTableAction()
    //set mouselistener to sort table on click of table header
    final JTableHeader head= jTable1.getTableHeader();
    head.addMouseListener(new java.awt.event.MouseAdapter()
    public void mouseClicked(java.awt.event.MouseEvent evt)
    Vector data= ((DefaultTableModel)jTable1.getModel ()).getDataVector();
    sortTable(data, head.columnAtPoint(evt.getPoint()));
    //set action map to change the default action performed for enter key pressed
    InputMap imap = jTable1.getInputMap(JTable.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    KeyStroke enterKey = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
    KeyStroke tabKey = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0);
    final Action oldAction= jTable1.getActionMap().get(imap.get(tabKey)); // get map to set enter key.
    imap.put(enterKey, "enter"); // set enter key
    Action newAction = new AbstractAction(){
    public void actionPerformed(ActionEvent e) {
    oldAction.actionPerformed(e);
    JTable table= (JTable)e.getSource();
    table.changeSelection(0,0,false,false);
    if(table.isCellEditable(0,0))
    String sTemp= (String)table.getValueAt(0,0);
    if(sTemp.length()>0) {
    if(bRenewItem)
    retrieveRcodeDetails("",sTemp);
    else
    processRCodeDetails(sTemp, e);
    }else
    table.editCellAt(0,0);
    jTable1.getActionMap().put("enter", newAction);
    jTable1.setPreferredScrollableViewportSize(jTable1.getPreferredSize());
    }

    Hi,
    I also am using the Bépo layout with an encrypted drive and encountered the same problem: the Return key does not work.
    It seems to work fine if you use the fr-bepo-latin9 keymap.
    # /etc/vconsole.conf
    KEYMAP=fr-bepo-latin9
    But I also looked at the files /usr/share/kbd/keymaps/i386/bepo/fr-bepo.map.gz and /usr/share/kbd/keymaps/i386/bepo/fr-bepo-latin9.map.gz (you can open gzipped files in vim directly). fr-bepo-latin9.map.gz defines keycode 28 (Return) but fr-bepo.map.gz does not.
    I modified fr-bepo.map.gz:
    # vim /usr/share/kbd/keymaps/i386/bepo/fr-bepo.map.gz # Append that line : "keycode 28 = Return".
    # mkinitcpio -p linux # Rebuild the initramfs.
    The Return key now works, but the Backspace (14, "Delete") and Shift (54) keys don’t work. I found that both the cf.map.gz (french canadian layout) and fr-bepo-latin9.map.gz files define those keycodes as well as other non-printing keys so I copied the following lines from fr-bepo-latin9.map.gz to fr-bepo.map.gz:
    keycode 1 = Escape Escape
    keycode 14 = Delete Delete
    keycode 15 = Tab Tab
    keycode 28 = Return
    keycode 29 = Control
    keycode 42 = Shift
    keycode 54 = Shift
    keycode 56 = Alt
    keycode 58 = Caps_Lock
    keycode 97 = Control
    It works! Don’t forget to rebuild the initramfs after you change the keymap file.
    # mkinitcpio -p linux
    I will send a message to the kbd and bépo projects mailing lists and report back.

  • Selection Problem with JTable

    Hello,
    i have a selection problem with JTable. I want to allow only single cell selection and additionally limit the selection to the first column.
    I preffered the style from MS Outlook Express where you can select the email accounts to edit.
    It is a table like this:
    Account name  |   Type  |   ...
    --------------|---------|---------------------
    Hotmail       |   POP3  |
    GMX           |   IMAP  |The selection should be only avaibable at 'Hotmail' or 'GMX' - not at 'POP3', 'IMAP' or as complete row selection.
    Please help me!
    Thanks.
    Warlock

    Maybe this will helpimport java.awt.*;
    import javax.swing.*;
    public class Test3 extends JFrame {
      public Test3() {
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Container content = getContentPane();
        String[] head = {"One", "Two"};
        String[][] data = {{"R1-C1", "R1-C2"}, {"R2-C1", "R2-C2"}};
        JTable jt = new JTable(data, head);
        jt.getColumnModel().setSelectionModel(new MyTableSelectionModel());
        content.add(new JScrollPane(jt), BorderLayout.CENTER);
        jt.setCellSelectionEnabled(true);
        jt.setRowSelectionAllowed(false);
        jt.setColumnSelectionAllowed(false);
        setSize(300, 300);
        setVisible(true);
      public static void main(String[] arghs) { new Test3(); }
    class MyTableSelectionModel extends DefaultListSelectionModel {
      public void setSelectionInterval(int index0, int index1) {
        super.setSelectionInterval(0, 0);
    }

  • OIM 9.1.0.2 - Weblogic JDBC Multi Data Sources for Oracle RAC

    Does OIM OIM 9.1.0.2 BP07 support Weblogic JDBC Multi Data Sources (Services>JDBC>Multi Data Sources) for Oracle RAC instead of inserting the "Oracle RAC JDBC URL" on JDBC Data Sources for xlDS and xlXADS (Services>JDBC>Data Sources> xlDS|xlXADS > Connection Poll> URL) ?
    If yes, is there are any other modifications that need to be made on OIM, or just changing the data sources?

    Yes, it's supported. You install against one instance directly of the Rac Server. Then you update the config.xml file and the jdbc resource in your weblogic server with the full rac address. It is documented for installation against RAC. http://docs.oracle.com/cd/E14049_01/doc.9101/e14047/database.htm#insertedID2
    -Kevin

  • Any body please can solve my problem that iam facing with JTable

    Dear sir,
    Iam doing an educational product using Swing as front end in that
    iam using JTables. And back end iam using sqlserver. With jtable iam
    facing very serious problem the problem is actually iam entering the values
    in all the columns after that iam pressing the save button its not
    saving but if i click on any of the columns and try to save its saving.
    please anybody can solve my problem.Please if a piece of code is there ill
    be very thankful to you. my mailid is [email protected]
    regards
    surya

    The problem is, the cellEditor does not know that editing has stopped and therefore has not updated the model (where the data actually resides). When you click off the cell to another cell, the first cell knows it must be done editing because you are leaving it. If you click a button (or anything other than another cell), the cell being edited has no knowledge of this. You need to call stopCellEditing() on the cell editor and your problem will be solved. To do this, put the following method into your code and call it when you click the button to clear, save or whatever you need to do.
    public void ceaseEditing() {    int row = this.getEditingRow();
      int col = this.getEditingColumn();
      if (row != -1 && col != -1)
        this.getCellEditor(row,col).stopCellEditing(); 
      }Hope this helped...

  • Load JDBC-Driver dynamically with JarClassLoader

    Hey!
    I have a problem loading JDBC drivers dynamically with a JarClassLoader:
    Code:
    public class URLLoaderTest {
      public static void main(String[] args) {
      try {
        URL[] urlList = {new File("D:\\jbuilder5\\SQLServerJDBC\\lib\\mssqlserver.jar").toURL(),
                         new File("D:\\jbuilder5\\SQLServerJDBC\\lib\\msbase.jar").toURL(),
                         new File("D:\\jbuilder5\\SQLServerJDBC\\lib\\msutil.jar").toURL()};
        ClassLoader classLoader = new URLClassLoader(urlList);
        Class c = Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver",true,classLoader);
        Object d = c.newInstance();
        DriverManager.registerDriver((Driver)d);
        // DriverManager.getDrivers()    Enumeration is empty
        Connection conn = DriverManager.getConnection("jdbc:microsoft:sqlserver://Server:1433","test","test");
        DatabaseMetaData meta = conn.getMetaData();
        System.out.println("JDBC driver version is " + meta.getDriverVersion());
      catch (Exception e) {System.out.println(e.getMessage());}
    }Problem:
    Till the DriverManager registraton everything is ok.
    The registerDriver Method throws no exception but if I call DriverManager.getDrivers() after calling the registerDriver Method an empty Enumeration is returned.
    So the driver is not loaded and DriverManager.getConnection throws an Exception (no suitable driver).
    If I include the driver jars into the Classpath everything is running (but that isn't what I want to do).
    Is there a solution for this problem? Maybe it is possible to load the data into the AppClassLoader??!!
    Thanx in advance.

    Found a solution!
    For everyone who is interested:
    public class URLLoaderTest {
      public static void main(String[] args) {
      try {
        URL[] urlList = {new File("D:\\jbuilder5\\SQLServerJDBC\\lib\\mssqlserver.jar").toURL(),
                         new File("D:\\jbuilder5\\SQLServerJDBC\\lib\\msbase.jar").toURL(),
                         new File("D:\\jbuilder5\\SQLServerJDBC\\lib\\msutil.jar").toURL()};
        ClassLoader classLoader = new URLClassLoader(urlList);
        Class c = Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver",true,classLoader);
        Object d = c.newInstance();
        Driver driver = (Driver)d;
        Properties prop = new Properties();
        prop.setProperty("user","test");
        prop.setProperty("password" ,"test");
        Connection conn = driver.connect("jdbc:microsoft:sqlserver://test:1433",prop);
        System.out.println("JDBC driver version is " + meta.getDriverVersion());
      catch (Exception e) {System.out.println(e.getMessage());}
    }

  • JDBC Receiver Adapter with Native SQL String

    Hi experts
    I need to use a JDBC Receiver Adapter with Message Protocol of Native SQL String, but I don´t understand how to create my data type for XML Document Format. I studied the following example from the SAP Library,
    INSERT INTO tableName (column-name1, column-name2, column-name3) VALUES(u2018column-value1u2019, u2018column-value2u2019, u2018column-value3u2019)
    i´ll be very thankful of your recommendations.

    Another simple way is..
    Create receiver data structure like this....
    <StatementName>
    <anyName action=u201DSQL_DMLu201D>
    <access>INSERT INTO tableName (column-name1, column-name2, column-name3) VALUES('$column-value1$', '$column-value2$', '$column-value3$')
    </access>
    <key>
      <column-value1>value1</column-value1>
      <column-value2>value2<column-value2>
       <column-value3>value3<column-value3>
    </key>
    </anyName > 
    </StatementName>
    Rest are all same.

  • Proxy to JDBC scenario data to be fetched from two dB

    Hello all,
    we have a  requirement in which  the data is sent from an abap program and using PI it will fetch the data from DB at client side,
    and we need to display the data in the report program.
    As we need the real time data and need to be displayed back in the Report program the processing time should be less than 30 sec.
    We have tried the scenario using synch Proxy-synch jdbc and we are getting the data with in time but we tried this with 1 DB.
    But now we have requirement change and  we need to look the data in 2 Data bases.
    we need to pass data through  client proxy(Synch) to PI and it should check the data in 2 DB and send back the data.
    the data sent back from the DB, we need to show in our ABAP program.
    Please send in your inputs so that i get some pointers regarding this requirement.
    Thanks
    Karandeep Singh

    HI Vijayashankar,
    Thanks for your reply.
    Please brief me the steps for using fork in BPM.
    Thanks
    Karandeep Singh.

  • HANA DB 1.00 Build 20 - Error import COPA Data with HANA STUDIO 1.00...

    Hi,
    Has anyone tried loading data records to HANA DB 1.00 Build 20 from the CTL files provided in     https://wiki.wdf.sap.corp/wiki/display/HANADemoenvironment/HowtoloadCOPAdata ?
    It was work on HANA DB 1.00 Build 15 but not with New Build...
    The procedure was exactly the same
    The creation of Tables is done but i have this error with import data with each csv files:
    Command with HANA Studio (Build 20):
                    load from '/tmp/export/TCURT.ctl' threads 4 batch 1000;
    Error:
                   Could not execute 'load from '/tmp/export/TCURT.ctl' threads 4 batch 1000'
                   SAP DBTech JDBC: [257]: sql syntax error: line 1 (at pos 3643214585)
    I tried also:  load from '/tmp/export/TCURT.ctl' -> same error...
    We have all privileges on the tmp folder and files
    I tried also to copy new data from source...
    Do you have an idea?
    Thanks for advance for help .
    Best regards,
    Eric MG

    Hello,
    LOAD TABLE command was not public - full syntax was never mentioned in any SAP guide on help.sap.com or Market Place (except SAP HANA Pocketbook-DRAFT). Therefore it is SAP internal syntax that can be changed anytime. And I guess this is what happened. Command is either deprecated or having different syntax.
    If you need to import CVS file I would suggest to use official way - either IMPORT command (which was also not very public before but since SP03 it is mentioned in SQL Script Guide) or best using SAP HANA Studio import functionality (just be sure you use CVS as type of file).
    You can find explanation of both ways in this blog:
    SAP HANA - Modeling Content Migration - part 2: Import, Post-migration Activities
    Tomas

  • Export data form JTable to excel

    Hi! i want to export data from JTable to excel.
    could you help me please?

    Despite your question looks doesn't seems to be very complex, I feel pity I am a newbie can not offer you the answers. I am more familiar with exporting data to excel in C#. I've worked with a Data Grid control, just like the JTable. Here are some C# code example. Maybe you can take them as a kind of reference.
    ExportToExcelML exporter = new ExportToExcelML(this.ketticGridView1);
    exporter.HiddenColumnOption = Kettic.WinForm.UI.Export.HiddenOption.DoNotExport;
    exporter.ExportVisualSettings = true;
    exporter.SheetMaxRows = ExcelMaxRows._1048576;
    exporter.SheetName = "NewSheet";
    exporter.SummariesExportOption = SummariesOption.DoNotExport;
    string fileName = "C:\\ExportedGridData1.xls";
    exporter.RunExport(fileName);

  • JDBC:ODBC, Resultset with 0 rows throws SqlException

    For short, I have used forte for java version 3.0 ea to create an application which is manipulating data in an MS SQLServer database. Further I have installed JDK 1.3.1 and JRE 1.3.1, running on WINDOWS 2000 os.
    The DB-configuring is set to binary sort order.
    When my program is running a "rs = stmt.executQuery() then the situation is:
    1) If this query results in 1 or more rows in the resultset, everything seems to work fine.
    2) But if the resultset doesn't contains any rows, which is a quit legal result and actually a succes criteria in a certain point in my prg., an SQLException is thrown stating "Invalid object name + 'database tablename in uppercase'". Although the db-tables name is in mixedletters (see the code below).
    For testing purpose I have worked out a quit simpel prg. which reflects the real prg. I enclose it for examining purpose.
    I certaintly hope somebody is able to guide me to a solution.
    Thanks in advance.
    Kind regards
    Kuno Reck
    IBC Systems A/S
    TestCode:
    import java.sql.*;
    import javax.swing.*;
    //import javax.swing.table.*;
    class DBTest {
    private static final String driver = "sun.jdbc.odbc.JdbcOdbcDriver",
    dbUrl = "jdbc:odbc:KEKVRF",
    comUser = "tbs", password = "tbs";
    private static Connection conn;
    private static Statement stmt;
    private static ResultSet rs;
    // String queryDdi = "SELECT DISTINCT N.DdiNumber FROM DdiNumbers N left
    join DdiGroups G on N.DdiNumber = G.DdiNumber and N.ProviderId = G.ProviderId
    WHERE 1 = 1 AND N.DdiNumber BETWEEN 35248305 AND 35248309 ORDER BY N.DdiNumber";
    // String queryDdi = "SELECT DISTINCT N.DdiNumber FROM DdiNumbers N left
    join DdiGroups G on N.DdiNumber = G.DdiNumber and N.ProviderId = G.ProviderId
    WHERE 1 = 1 AND N.DdiNumber = 35248307 ORDER BY N.DdiNumber";
    String queryDdi = "SELECT DdiNumber FROM DdiNumbers WHERE DdiNumber =
    35548307";
    public static void main (String[] args){
    DBTest dbtest = new DBTest();
    public DBTest() {
    try{
    Class.forName(driver);
    conn = DriverManager.getConnection(dbUrl, comUser, password);
    java.sql.DriverManager.setLogStream(java.lang.System.out);
    stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
    ResultSet.CONCUR_READ_ONLY);
    rs = stmt.executeQuery(queryDdi);
    if (rs.isBeforeFirst()){
    while (rs.next()) {
    // BEM?RK! KolonneV?rdierne skal l?ses ud i samme r?kkef?lge som de
    selectes i sql-statementet.
    System.out.println("DdiNumber = "+rs.getString("DdiNumber"));
    else{
    JOptionPane.showMessageDialog(null, "> Ddi-number does not exist
    < ", "Validation of input fields", JOptionPane.ERROR_MESSAGE);
    catch (SQLException e){
    JOptionPane.showMessageDialog(null, "No matching records found, " +
    e.getMessage(), "SQLException", JOptionPane.ERROR_MESSAGE);
    System.exit(0);
    catch (ClassNotFoundException cnfe){
    JOptionPane.showMessageDialog(null, "ClassNotFoundException, " +
    cnfe.getMessage(), "ClassNotFoundException", JOptionPane.ERROR_MESSAGE);
    LogStream:
    C:\jdk1.3.1\bin>java DBTest
    *Connection.createStatement
    Allocating Statement Handle (SQLAllocStmt), hDbc=148181752
    hStmt=148185176
    Setting statement option (SQLSetStmtOption), hStmt=148185176, fOption=6,
    vParam=3
    Setting statement option (SQLSetStmtOption), hStmt=148185176, fOption=7,
    vParam=1
    Registering Statement sun.jdbc.odbc.JdbcOdbcStatement@17d257
    *Statement.executeQuery (SELECT DdiNumber FROM DdiNumbers WHERE DdiNumber =
    3554830
    7)
    *Statement.execute (SELECT DdiNumber FROM DdiNumbers WHERE DdiNumber = 35548307)
    Free statement (SQLFreeStmt), hStmt=148185176, fOption=0
    Executing (SQLExecDirect), hStmt=148185176, szSqlStr=SELECT DdiNumber FROM
    DdiNumbe
    rs WHERE DdiNumber = 35548307
    Number of result columns (SQLNumResultCols), hStmt=148185176
    value=1
    Get statement option (SQLGetStmtOption), hStmt=148185176, fOption=6
    value=3
    SQLWarning: reason(Result set type has been changed.)
    Number of result columns (SQLNumResultCols), hStmt=148185176
    value=1
    Number of affected rows (SQLRowCount), hStmt=148185176
    value=0
    Fetching (SQLFetchScroll), hStmt=148185176
    End of result set (SQL_NO_DATA)
    Get statement option (SQLGetStmtOption), hStmt=148185176, fOption=14
    RETCODE = -1
    ERROR - Generating SQLException...
    SQLException: SQLState(24000) vendor code(0)
    java.sql.SQLException: [Microsoft][ODBC Driver Manager] Invalid cursor state
    at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6031)
    at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:6188)
    at sun.jdbc.odbc.JdbcOdbc.SQLGetStmtOption(JdbcOdbc.java:3773)
    at sun.jdbc.odbc.JdbcOdbcResultSet.calculateRowCount
    (JdbcOdbcResultSet.java
    :5982)
    at sun.jdbc.odbc.JdbcOdbcResultSet.initialize
    (JdbcOdbcResultSet.java:150)
    at sun.jdbc.odbc.JdbcOdbcStatement.getResultSet
    (JdbcOdbcStatement.java:420)
    at sun.jdbc.odbc.JdbcOdbcStatement.executeQuery
    (JdbcOdbcStatement.java:250)
    at DBTest.<init>(DBTest.java:27)
    at DBTest.main(DBTest.java:18)
    Fetching (SQLFetchScroll), hStmt=148185176
    End of result set (SQL_NO_DATA)
    *Connection.createStatement
    Allocating Statement Handle (SQLAllocStmt), hDbc=148181752
    hStmt=148186208
    Setting statement option (SQLSetStmtOption), hStmt=148186208, fOption=6,
    vParam=0
    Setting statement option (SQLSetStmtOption), hStmt=148186208, fOption=7,
    vParam=1
    Registering Statement sun.jdbc.odbc.JdbcOdbcStatement@19c082
    *Statement.executeQuery (SELECT COUNT(*) FROM DDINUMBERS WHERE DDINUMBER =
    3554830
    7)
    *Statement.execute (SELECT COUNT(*) FROM DDINUMBERS WHERE DDINUMBER = 35548307)
    Free statement (SQLFreeStmt), hStmt=148186208, fOption=0
    Executing (SQLExecDirect), hStmt=148186208, szSqlStr=SELECT COUNT(*) FROM
    DDINUMBE
    RS WHERE DDINUMBER = 35548307
    RETCODE = -1
    ERROR - Generating SQLException...
    SQLException: SQLState(S0002) vendor code(208)
    java.sql.SQLException: [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid
    objec
    t name 'DDINUMBERS'.
    at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6031)
    at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:6188)
    at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:2494)
    at sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:334)
    at sun.jdbc.odbc.JdbcOdbcStatement.executeQuery
    (JdbcOdbcStatement.java:249)
    at sun.jdbc.odbc.JdbcOdbcResultSet.calculateRowCount
    (JdbcOdbcResultSet.java
    :6063)
    at sun.jdbc.odbc.JdbcOdbcResultSet.initialize
    (JdbcOdbcResultSet.java:150)
    at sun.jdbc.odbc.JdbcOdbcStatement.getResultSet
    (JdbcOdbcStatement.java:420)
    at sun.jdbc.odbc.JdbcOdbcStatement.executeQuery
    (JdbcOdbcStatement.java:250)
    at DBTest.<init>(DBTest.java:27)
    at DBTest.main(DBTest.java:18)
    ResultSet.finalize sun.jdbc.odbc.JdbcOdbcResultSet@4ac268
    ResultSet.finalize sun.jdbc.odbc.JdbcOdbcResultSet@216869
    *ResultSet.close
    C:\jdk1.3.1\bin>

    Hi,
    my suggestion: you can't use isBeforeFirst() on empty result set. Try following:
    rs = stmt.executeQuery(queryDdi);
    int count = 0;
    while (rs.next()) {
      count++;
      System.out.println("DdiNumber = "+rs.getString("DdiNumber"));
    if (count == 0) {
    JOptionPane.showMessageDialog(null, "> Ddi-number does not exist < ", "Validation of input fields", JOptionPane.ERROR_MESSAGE);
    }Best Regards,
    Martin

  • How to read data with different XML schemas within the single connection?

    I have Oracle 11g database
    I access it through jdbc:oracle:thin, version 11.2.0.3, same as xdb.
    I have several tables, each has one XMLType column, all schema-based.
    There are three different XML schemata registered in the DB
    I may need to read the XML data from several tables.
    If all the XMLTypes have the same XML schema ,there is no problem,
    If the schemata are different, the second read throws BindXMLException.
    If I reset the connection between the reads of the XMLType column with different schemata, it works.
    The question is: how can I configure the driver, or the connection to be able to read the data with different XML schemata without resetting the connection (which is expensive).
    The code to get the XMLType data is textbook implementation:
    1   ResultSet resultSet = statement.executeQuery( sql ) ;
    2   String result = null ;
    3    while(resultSet.next()) {
    4   SQLXML sqlxml = resultSet.getSQLXML(1) ;
    5   result = sqlxml.getString() ;
    6   sqlxml.free();
    7   }
    8   resultSet.close();
    9    return result ;

    It turns out, that I needed to serialize the XML on the server and read it as Blob. Like this:
    1    final Statement statement = connection.createStatement() ;
    2    final String sql = String.format("select xmlserialize(content xml_content_column as blob encoding 'UTF-8') from %s where key='%s'", table, key ) ;
    3   ResultSet resultSet = statement.executeQuery( sql ) ;
    4   String result = null ;
    5    while(resultSet.next()) {
    6   Blob blob = resultSet.getBlob( 1 );
    7   InputStream inputStream = blob.getBinaryStream();
    8   result = new Scanner( inputStream ).useDelimiter( "\\A" ).next();
    9   inputStream.close();
    10   blob.free();
    11   }
    12   resultSet.close();
    13   statement.close();
    14
    15   System.out.println( result );
    16    return result ;
    17
    Then it works. Still, can't get it work with XMLType in resultset.On the client unwrapping XML blows up when trying to switch to different XML schema. JDBC/XDB problem?

  • Compare Date with Timezone

    Hi,
    I have a Date which is stored in the Database with the timezone like GMT, I have a java.util.Date which is selected in my UI from a Customized Calendar, I am converting this Date with timezone and want to compare this date with the date with timezone stored in the DB? How to accomplish this, please shed some light into this?
    Thanks.

    797836 wrote:
    I have a Date which is stored in the Database with the timezone like GMT, I have a java.util.Date which is selected in my UI from a Customized Calendar, I am converting this Date with timezone and want to compare this date with the date with timezone stored in the DB?As Parul said, Date does not involve a timezone. I think you need to clarify what you mean by "I am converting this Date with timezone", because it doesn't make much sense to me.
    BTW: If the date in your database is a standard SQL Date, then it will be converted to a java.sql.Date when you read it into Java with JDBC. And java.sql.Date is directly comparable with java.util.Date (in fact, it's a subclass).
    Winston

Maybe you are looking for

  • How to ctreate report in dev environment

    Hi all, Can I create report on the dev evironment only by having VPN acessto that machine . If yes then when I logged in to the financial reporting stdio client of the Dev environment m/c it gave me the following error. You are not authorized to use

  • Creating sitemap for webpage in new iWeb...

    I am having a lot of trouble getting a sitemap to generate for my website that I built using iWeb. It will only generate a map for the very first page and none of the rest of them. Has anyone else had this issue? www.mtbtrailreview.com

  • Problems saving PDF comments in Reader X

    Hi, I'm wondering if anyone else has encountered this behavior? I created a PDF from FrameMaker 8 using Acrobat 8. A collegue reviewed the file and made comments using the Comment and Markup Tools feature in Acrobat Reader 9. Later he upgraded to Rea

  • Signal Handling by JVM : a probable bug

    I am facing the following problem. when i kill a running java code by (CTRL C SIGINT), then the sub processes created by the parent java program using "exec" call didn't get terminated. I ran the code on Solaris machine. This OS supports cascading te

  • Solaris 11: configuring/installing/verifying zone: dataset does not exist

    Hello all, I am working my way through setting up a dataset via the instructions listed here http://docs.oracle.com/cd/E23824_01/html/821-1460/z.conf.start-85.html http://docs.oracle.com/cd/E23824_01/html/821-1460/z.inst.task-2.html I am now trying t