Populate JComboBox from a database...i'm new!

I want to populate a JComboBox from a Database. I have my query set up and I have seen people's solutions that look like this:
JComboBox CbTeamName = JComboBox();
try{
//Register Driver
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//Get Connection
conn = DriverManager.getConnection("jdbc:odbc:SLeague", "", "");
System.out.println("Connect Database succesfully");
//Create SQL Statement
stmt = conn.createStatement();
rs = stmt.executeQuery("SELECT teamName FROM teamInfo");
while(rs.next()){
CbTeamName.addItem(rs.getString("teamName"));
stmt.close(); //Close the SQL Statement
conn.close(); //Close the connection of Database
System.out.println("Connection close");
catch(SQLException sqlex) {
System.out.println(sqlex);
catch(Exception ex) {
System.out.println(ex);
However, I have a problem in that my database connection is in another class (which is in another package). I added this line of code into my class, which has my connection in it:
DataAccess.AppointmentDA.initialize();
Basically I can't figure where to put what code. I don't even know if I am explaining this correctly, but its 1AM and I am frustrated. If you think you can help me I would GREATLY appreciate it.

Hi,
In the class where you have your database code,add a new method
Vector getTeamNames()
Vector teamNames;
rs = stmt.executeQuery("SELECT teamName FROM teamInfo");
while(rs.next()){
teamNames.addElement(rs.getString("teamName"));
stmt.close();
return teamNames;
In the place where you need to add this in combo you can have the following code :
Vector teamNames=db.getTeamNames();
for(int i=0;i<teamNames.size();i++){
CbTeamName.addItem(teamNames.elementAt(i));
So you can maintain the database part and view part in seperate classes/packages.
Hope this helps,
Ranga.

Similar Messages

  • Auto populate forms from a database

    I'm new to LiveCycle and was wondering if there is a way to auto populate a form created in LiveCycle. Essentially, I have an Excel spreadsheet with a thousand or so entries. I'm looking to create a sort of cover page from all this data for each individual entry featuring name, address, etc. I can convert the spreadsheet to an XML file, but after that I get lost. Is there a way to set up a form so that it can autocomplete all of the fields using an XML file or is this something that I need to do manually?

    LiveCycle Forms is designed to accept a form template and an XML datastream and merge them together to provide a populated PDF that is interactive.  For a non-interactive version of the template LiveCycle Output would be utilized.  There are a number of methods to interact with LiveCycle but it sounds like the easiest method for you would be to use a watched folder where you would simply copy your XML files and LiveCycle will read the file and produce the PDF files.  To start use Workbench and create a process that uses the RenderPDFForm operation.  You might want to start with these http://www.adobe.com/devnet/livecycle/videotraining.html

  • Migrating from old database version to newer on

    Hi All,
    We have an very old version of Oracle database, version 7.3.4.4. We want to upgrade or migrate to the newest version. What version can 7.3 be able to upgrade/migrate to (8i, 9i, 10g or 11g)?
    Thank you.

    The biggest supported jump you can do is to 9.2.
    http://download.oracle.com/docs/cd/B10501_01/server.920/a96530/migprep.htm#1006849
    Nicolas.

  • Populate ComboBox from database - NOT using Flex Data Services

    Hi there,
    We are using CF with Flex but are not using the Flex Data
    Service. I'm very much a newb and I'm having trouble finding any
    information on how to populate controles from a database without
    using Flex Data Service. Any help would be greatly appreciated.
    First I have a page... JobSearch.mxml that contains a combo
    box that I want to populate with the job_id and job_title from a
    MSSQL database.
    In Flex in the RDS DataView I used the "Create CFC" Wizard
    which generated "job.cfc" and "jobGateway.cfc". It also generated
    "job.as".
    The CF Function that selects the data appears to be defaulted
    and called "load" and the .as function is called simply "job".
    So, that all looks great. But I can't find any information on
    what I need to have on my JobSearch.mxml to actually get this data
    into the comboBox.
    I did:
    <mx:Script>
    <![CDATA[
    [Bindable]
    public var jobData:job = null;
    ]]>
    </mx:Script>
    And then:
    <mx:ComboBox
    text="{jobData.job_title}"></mx:ComboBox>
    But I'm being told "Type was not found or was not a
    complie-time constant: job"
    I guess I'm missing something, or doing something way
    wrong... I just don't know enough of Flex at this point to know
    what it is.
    Thanks!
    April

    Using php or asp is not an option, as we are a Cold Fusion
    House.
    I was looking at an article on Ben Forta's blog (
    http://www.forta.com/blog/index.cfm?mode=e&entry=1786)
    and following his example I did this... only it doesn't work:
    I'm very very new to Flash and we are using ColdFusion but
    are not using Flex Data Services. I've been trying to figure out
    how to populate a combobox from a database and I'm just not having
    any luck.
    My project is called "PreTraffic". I have my main file as
    "JobSearch.mxml" and a folder under the root named "cfc" with a
    file called "job.cfc".
    job.cfc contains the following code:
    <cfcomponent>
    <!--- Get jobs --->
    <cffunction name="GetJob" access="remote"
    returntype="query" output="false">
    <cfset var job="">
    <cfset var results="">
    <cfquery datasource="discsdev" name="job">
    SELECT job_id, job_title
    FROM job
    WHERE status = 'O'
    ORDER BY job_title
    </cfquery>
    <cfquery dbtype="query" name="results">
    SELECT job_title AS label, job_id AS data
    FROM job
    ORDER BY label
    </cfquery>
    <cfreturn results>
    </cffunction>
    </cfcomponent>
    And JobSearch.mxml has the following code:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application
    xmlns:mx="
    http://www.adobe.com/2006/mxml"
    xmlns="*"
    layout="absolute"
    backgroundGradientColors="[#ffffff, #d0d0d0]"
    creationComplete="InitApp()">
    <mx:Style source="style.css" />
    <mx:Script>
    <![CDATA[
    public function InitApp():void {
    jobSvc.GetJob();
    ]]>
    </mx:Script>
    <!-- ColdFusion CFC (via AMF) -->
    <mx:RemoteObject id="jobSvc" destination="PreTraffic"
    showBusyCursor="true" />
    <mx:VBox label="Job History" width="100%" height="100%"
    x="10" y="92">
    <mx:Label text="Search jobs by"/>
    <mx:Form label="Task" width="100%">
    <mx:FormItem label="Job Name:">
    <mx:ComboBox id="jobNameCB"
    dataProvider="{jobSvc.GetJob.results}"></mx:ComboBox>
    </mx:FormItem>
    </mx:Form>
    <mx:HBox>
    <mx:Button label="Search"/>
    <mx:Button label="Clear"/>
    </mx:HBox>
    </mx:VBox>
    </mx:Application>
    My Compiler thingy points to:
    -services
    "/Volumes/flexwwwroot/WEB-INF/flex/job-services-config.xml" -locale
    en_US
    and job-services-config.xml contains the following code:
    <destination id="PreTraffic">
    <channels>
    <channel ref="my-cfamf"/>
    </channels>
    <properties>
    <source>flex.pretraffic.cfc.job</source>
    <lowercase-keys>true</lowercase-keys>
    </properties>
    </destination>
    Well, when I run the app... the combobox is not populated...
    Can anyone help with what I've done wrong?
    Thanks!
    April

  • [b] Populating List Box from MySQL Database[/b]

    Hi all,
    I'm trying to populate a JComboBox from MySQL database, I Have an applet which send's the query to a server through sockets on the localhost, but when i try to retrieve the result set from the MySQL database, i get an index out of bounds exception, It's probably something simple, any help regarding the above problem!! I've included the code below!!
    Cheers
    Dave
    java.lang.ArrayIndexOutOfBoundsException: 1
    at dbWrapper1.Select(dbWrapper1.java:97)
    at TestUpdateDB.main(TestUpdateDB.java:29)
    Applet Code:
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.sql.*;
    import java.util.*;
    import java.io.*;
    import java.net.*;
    *     @version  04/18/05
    *     @author David Lawless
    public class cust extends JApplet implements ActionListener
    //Declare Labels for Form
    private JLabel titleLabel;
    private JLabel firstNameLabel;
    private JLabel lastNameLabel;
    private JLabel addressLabel;
    private JLabel countyLabel;
    private JLabel countryLabel;
    //Declare Input fields for user
    private JTextField firstNameText;
    private JTextField lastNameText;
    private JTextField addressLineOneText;
    private JTextField addressLineTwoText;
    private JTextField addressLineThreeText;
    //Declare list for title box
    private JComboBox titleList;
    private String[] title = {"Mr.","Mrs.","Miss","Ms","Dr."};
    //Declare list for county box
    private JComboBox countyList;
    //Called when this applet is loaded into the browser.
    public void init()
    lookAndFeel();
    //Initialise Labels
    firstNameLabel = new JLabel("First Name * ");
    lastNameLabel = new JLabel("Last Name * ");
    titleLabel = new JLabel("Title * ");
    addressLabel = new JLabel("Address *");
    countyLabel = new JLabel("County *");
    countryLabel = new JLabel("Country *");
    //Initialise title List
    titleList = new JComboBox( title );
    titleList.setActionCommand("Title");
    //Set up Text fields
    firstNameText = new JTextField(30);
    firstNameText.setToolTipText("Please enter your first name here");
    lastNameText = new JTextField(30);
    lastNameText.setToolTipText("Please enter your surname here");
    addressLineOneText = new JTextField(30);
    addressLineTwoText = new JTextField(30);
    addressLineThreeText = new JTextField(30);
    //Retrieve County List From Database
    //countyList = new JComboBox( counties );
    try
         try
              Socket mySocket = new Socket ("127.0.0.1", 1983 );
              ObjectOutputStream out = new ObjectOutputStream(mySocket.getOutputStream());
              String entry1 ="SELECT county FROM data";
              out.writeObject(new String(entry1));
              ObjectInputStream in = new ObjectInputStream(mySocket.getInputStream());
              int size = in.readInt();
              Object [] results = new Object[size];
              for (int i=0; i < size  ; i++ )
                   results[i] = in.readObject();
              countyList = new JComboBox( results );
              countyList.setActionCommand("County");
              mySocket.close ();
         catch (Exception exp)
              exp.printStackTrace();
    // detect problems interacting with the database
    catch ( Exception sqlException )
         System.exit( 1 );
    //set up command buttons
    submitButton = new JButton("Submit");
    submitButton.setToolTipText("Click here to submit your details ");
    submitButton.addActionListener(this);
    cancelButton = new JButton("Cancel");
    cancelButton.setToolTipText("Click here to cancel order");
    cancelButton.addActionListener(this);
    Container topLevelContainer = getContentPane();
    getContentPane().setBackground(Color.blue);
    //Create Layout
    JPanel contentPane = new JPanel();
    //Set transparent background instead of blue
    contentPane.setBackground(Color.white);
    contentPane.setLayout(null);
    contentPane.setOpaque(true);
    titleLabel.setBounds(37,10,75,20);
    contentPane.add(titleLabel);
    firstNameLabel.setBounds(93,10,100,20);
    contentPane.add(firstNameLabel);
    lastNameLabel.setBounds(198,10,100,20);
    contentPane.add(lastNameLabel);
    titleList.setBounds(37,35,50,20);
    contentPane.add(titleList);
    firstNameText.setBounds(93,35,100,20);
    contentPane.add(firstNameText);
    lastNameText.setBounds(198,35,100,20);
    contentPane.add(lastNameText);
    addressLabel.setBounds(37,65,100,20);
    contentPane.add(addressLabel);
    addressLineOneText.setBounds(37,90,125,20);
    contentPane.add(addressLineOneText);
    addressLineTwoText.setBounds(37,115,125,20);
    contentPane.add(addressLineTwoText);
    addressLineThreeText.setBounds(37,140,125,20);
    contentPane.add(addressLineThreeText);
    countyLabel.setBounds(37,165,100,20);
    contentPane.add(countyLabel);
    countyList.setBounds(37,190,100,20);
    contentPane.add(countyList);
    submitButton.setBounds(60,250,100,20);
    contentPane.add(submitButton);     
    cancelButton.setBounds(180,250,100,20);
    contentPane.add(cancelButton);
    topLevelContainer.add(contentPane);
    }//End init()
    static void lookAndFeel()
         try
              UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
         catch(Exception e)
    }//End look and feel method
    public synchronized void actionPerformed(ActionEvent e)
    String actionCommand = e.getActionCommand();
    if (e.getSource() instanceof JButton)
         if (actionCommand.equals("Cancel"))
                   int returnVal = JOptionPane.showConfirmDialog(null,
                        "Are you sure you want cancel and discard your order?",
                        "Cancel Order", JOptionPane.YES_NO_OPTION);
                   if(returnVal == JOptionPane.YES_OPTION)
                        System.exit(0);
         if (actionCommand.equals("Submit"))
              firstName = firstNameText.getText();
              Surname = lastNameText.getText();
         }//end action command for submit button
    }//end method actionperformed
    }//End class customerDatabase Connection Code:
    import java.sql.*;
    import java.util.*;
    class dbWrapper1
        private Statement statement;
        private Connection connection;
        private String strUserName;
        private String strPassword;
         Object [] results = null;
         static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
         static final String DATABASE_URL = "jdbc:mysql://localhost:3306/ecommerce";
        public dbWrapper1()
            // the DSN for the Db connection
            strUserName = "root";
            strPassword = "password";
        public void Open()
            try
                // Load the jdbc-odbc bridge driver
                Class.forName ( JDBC_DRIVER );
                   //                    ***** TESTING PURPOSES *****
                   //Check currently loaded drivers
                   System.out.println("Currently loaded drivers...");   
                   for
                        Enumeration enum1 = DriverManager.getDrivers() ;
                        enum1.hasMoreElements();
                   System.out.println(enum1.nextElement().getClass().getName());
                // Attempt to connect to a driver.
                connection = DriverManager.getConnection ( DATABASE_URL, strUserName, strPassword );
                // Create a Statement object so we can submit
                // SQL statements to the driver
                statement = connection.createStatement();
            catch (SQLException ex)
                while (ex != null)
                    System.out.println ("SQL Exception:  " + ex.getMessage () );
                    ex = ex.getNextException ();
            catch (java.lang.Exception ex)
                ex.printStackTrace ();
        public void Update( String strUpdate )
            try
                // Submit an update or create
                statement.executeUpdate( strUpdate );
              catch (SQLException ex)
                while (ex != null)
                    System.out.println ("SQL Exception:  " + ex.getMessage () );
                    ex = ex.getNextException ();
        public Object[] Select( String strQuery )
            try
                // Submit a query, creating a ResultSet object
                ResultSet resultSet = statement.executeQuery( strQuery );
                // process query results
                   ResultSetMetaData metaData = resultSet.getMetaData();
                   int numberOfColumns = metaData.getColumnCount();
                   results = new Object[numberOfColumns];
                   while ( resultSet.next() )
                        for ( int i = 1; i <= numberOfColumns; i++ )
                             results[i] = resultSet.getObject(i);
                             System.out.print(resultSet.getString(i) + " | " );
                        System.out.println();
                   resultSet.close();
            catch (SQLException ex)
                while (ex != null)
                    System.out.println ("SQL Exception:  " + ex.getMessage () );
                    ex = ex.getNextException ();
              for (int i=0;i<results.length ;i++ )
                   System.out.println(results);
              return results;
    public void Close()
    try
    statement.close();
    connection.close();
    catch (SQLException ex)
    while (ex != null)
    System.out.println ("SQL Exception: " + ex.getMessage () );
    ex = ex.getNextException ();
    Server Code:
    import java.io.*;
    import java.net.*;
    public class TestUpdateDB
         public static void main(String[] args)
              System.out.println ( "Server is active" );
              try {
              ServerSocket sock = new ServerSocket ( 1983 );
              while ( true )
                   try
                        Socket mySock = sock.accept();
                        ObjectInputStream iStream = new ObjectInputStream(mySock.getInputStream());
                        ObjectOutputStream oStream = new ObjectOutputStream(mySock.getOutputStream());
                        Object temp = iStream.readObject();
                        String entry = (String)temp;
                        System.out.println ( entry );
                        dbWrapper1 myDB = new dbWrapper1();
                        myDB.Open();
                        Object [] query = myDB.Select(entry);
                        int size = query.length;
                        oStream.writeInt(size);
                        for (int i=1 ; i <= query.length ; i++)
                             oStream.writeObject( query );
                        myDB.Close();
                   catch ( Exception exp )
                        exp.printStackTrace ();
              catch ( Exception exp ) {
                exp.printStackTrace();

    Sir,
    The exception is probably in here.
    for ( int i = 1; i <= numberOfColumns; i++ ){
      results[i] = resultSet.getObject(i);
      System.out.print(resultSet.getString(i) + " | " );
    }ResultSet counting begins with 1 but array indexing begins with 0 your code should look more like.
    for ( int i = 0; i <= numberOfColumns; i++ ){
      results[i] = resultSet.getObject(i+1);
      System.out.print(resultSet.getString(i+1) + " | " );
    }Sincerely,
    Slappy

  • Adding content from a database

    Hi there, I'm looking for a way to add content to a JComboBox from a database. I have the code to connect the database to my application working fine but am struggling to find the appropriate way to make my JComboBox display data from my database. I'll leave all the code I have at present...
    import java.sql.*;
    import java.io.IOException;
    import java.io.*;
    import java.util.Properties;
    public class ConnectDB {
         public static void init(String fileName)
         throws  IOException, ClassNotFoundException
              Properties props = new Properties();
              FileInputStream in = new FileInputStream(fileName);
              props.load(in);
              String driver = props.getProperty("jdbc.driver");
              url = props.getProperty("jdbc.url");
              username = props.getProperty("jdbc.username");
              password = props.getProperty("jdbc.password");
              Class.forName(driver);  
         public static Connection getConnection() throws SQLException
              return DriverManager.getConnection(url,username,password);
         private static String url;
         private static String username;
         private static String password;
    }     (I obviously have a text file in my folder with my connection details)
    Then I'm trying to build a GUI in netbeans that will retrieve and update my database so I have something like this...
        private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                        
            jComboBox1.addItem("Please Click Button");
            try{
            ConnectDB myDB = new ConnectDB();
            myDB.init("DBoracle.txt");
            Connection conn = null;
            conn = myDB.getConnection();
            String query = "select * from Employee";
            Statement stmt = null;
            stmt = conn.createStatement();
            ResultSet rs = stmt.executeQuery(query);
            rs.next();
            String s = rs.getString(2);
            //Return the second entry from my database and add it to my JComboBox
            // in theory i'll be adding a loop later to add all the entries to my JComboBox
            jComboBox.setItem(s);
            catch(Exception e){}
        }                                     

    Thanks cotton for at least trying to point out my errors, I am only too aware of my lack of experience in doing this sort of thing hence why I'm posting here I'm a student trying to learn about these things and at the moment am admittingly struggling with it. I have read and followed the JDBC tutorial, infact that's where I started with this but it is at best limited and could maybe do with some more sample code on expanding the idea. It does however point to the fact that it is kinda limited in how it returns data:
    The ResultSet.getXXX methods are the only way to retrieve data from a ResultSet object, which means that you have to make a method call for each column of a row. It is unlikely that this is the cause of a performance problem, however, because it is difficult to see how a column could be fetched without at least the cost of a function call in any scenario. We welcome input from developers on this issue.
    Perhaps some of the developers on here could help solve this issue...
    I know my code is a bit messy but it's the trial and error approach I use, cumbersome I know but it's all I know with my limited knowledge. Probably not the best for posting on here but this is my near complete code. The extra textfield will be used to return data from a trigger which tested ok too. So my problem is I want to make textfield1 a combobox that returns all my primary keys from my table and then I could click on one and all my textfields would reflect my choice. e I'm guessing I'd be using an actionListener approach? I don't need the actual code for it I'm quite happy to plough on and try and figure it out for myself cos it's how I'll learn just want a suggestion on how I would approach it..
    import java.sql.Connection;
    import java.sql.ResultSet;
    import java.sql.Statement;
    public class NewJFrame extends javax.swing.JFrame {
        /** Creates new form NewJFrame */
        public NewJFrame() {
            initComponents();
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
       //Removed this code cos post too big!
        private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
            try{
            ConnectDB myDB = new ConnectDB();
            myDB.init("DBoracle.txt");
            Connection conn = null;      
            conn = myDB.getConnection();
            String query = "select * from SYSTEM.monitoringLab";
         Statement stmt = null;
            stmt = conn.createStatement();
            ResultSet rs = stmt.executeQuery(query);
            //rs.next();
            // this was being used earlier to test that I was getting my results set
            String s = rs.getString(1);
            String t = rs.getString(2);
            String u = rs.getString(3);
            String v = rs.getString(4);
            String w = rs.getString(5);
            String x = rs.getString(6);
            jTextField1.setText(s);
            jTextField2.setText(t);
            jTextField3.setText(u);
            jTextField4.setText(v);
            jTextField5.setText(w);
            jTextField6.setText(x);
            conn.close();
            stmt.close();
            catch(Exception e){
            System.err.println("Got an exception! ");
            System.err.println(e.getMessage());
        private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
            jTextField1.setText(null);
            jTextField2.setText(null);
            jTextField3.setText(null);
            jTextField4.setText(null);
            jTextField5.setText(null);
            jTextField6.setText(null);
        private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
            try{
            ConnectDB myDB = new ConnectDB();
            myDB.init("DBoracle.txt");
            Connection conn = null;
            conn = myDB.getConnection();
            Statement stmt = null;
            stmt = conn.createStatement();
            stmt.executeUpdate("INSERT INTO SYSTEM.monitoringLab values ("
                    + jTextField1.getText() + "," + jTextField2.getText() + ","
                    + jTextField3.getText() + "," + jTextField4.getText() + ","
                    + jTextField5.getText() + "," + jTextField6.getText() + ")");
            conn.close();
            stmt.close();
            catch(Exception e){
            System.err.println("Got an exception! ");
            System.err.println(e.getMessage());
        * @param args the command line arguments
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new NewJFrame().setVisible(true);
        // Variables declaration - do not modify
        private javax.swing.JButton jButton1;
        private javax.swing.JButton jButton2;
        private javax.swing.JButton jButton3;
        private javax.swing.JLabel jLabel1;
        private javax.swing.JLabel jLabel2;
        private javax.swing.JLabel jLabel3;
        private javax.swing.JLabel jLabel4;
        private javax.swing.JLabel jLabel5;
        private javax.swing.JLabel jLabel6;
        private javax.swing.JLabel jLabel7;
        private javax.swing.JLabel jLabel8;
        private javax.swing.JTextField jTextField1;
        private javax.swing.JTextField jTextField2;
        private javax.swing.JTextField jTextField3;
        private javax.swing.JTextField jTextField4;
        private javax.swing.JTextField jTextField5;
        private javax.swing.JTextField jTextField6;
        private javax.swing.JTextField jTextField7;
        // End of variables declaration
    }Edited by: jojololo on Dec 11, 2009 4:44 AM

  • How to display data from a database to a  JComboBox  JTextField

    Hello
    I was wondering I have a database called "PAYTYPE" and have a colums called
    EMPLOYEETYPE     PAYBASIC     PAYSUNDAY     PAYHOLIDAY     PAYPERIOD
    What i want to do is display the list of EMPLOYEETYPE in a combo box(Which i got this part working),
         try{
              ResultSet rs = db.getResult("Select * FROM PAYTYPE");
              while(rs.next())
                   payTypeField.addItem(rs.getString(2));
              }catch(SQLException e)
              }When an item is selected from the combo box then the information thats in PAYBASIC,PAYSUNDAY,PAYHOLIDAY, PAYPERIOD will be displayed in textfields
    this is the problem im trying to solve
    Any Ideas ??????

    What im trying to do is the following
    on my Gui i have 1 JComboBox and 3 JtextFields
    The Jcombo box is populated by the data base
    try{     
              ResultSet rs = db.getResult("Select * FROM EMPLOYEEPAYTYPE");
              while(rs.next())
                   payTypeField.addItem(rs.getString(2));
              }catch(SQLException e)
              }Now that i have the JComboBox filled I want the other 3 JTextField to be populated with the information that been selected by the JComboBox
    I under stand there needs to be a .addActionListener(this) to the JComboBox
                    payTypeField = new JComboBox();
                payTypeField.setBounds(130, 10,100,20);
                payTypeField.addActionListener(this);
                payTypeField.addItemListener(this);
                 c.add(payTypeField);I would just like the steps that i need to take in order to fill the JTextBoxes in pudoscode
    The information that i need will need to be pulled from the database - EMPLOYEEPAYTYPE
    Thanks
    Jon

  • Form does not show "new" records from SQL Database

    I have a PDF form that pulls data from a SQL Server.  The fields in
    the PDF are populated from the database after selecting a specific
    record from a drop down and then clicking on a button labeled "Fill".
    The problem is that the dropdown does not display new records that
    have been recently added to the database.  I have to open the form up
    in designer then save it, (*note - I change nothing at this point.)
    Then when the form is opened back up in Adobe the dropdown show all
    the records including the new ones.  I even put a manual refresh on
    form to try and fix this an it did not help. Seriously stumped.
    Any help is greatly appreciated.
    Here is my code for the dropdown.
    ++++++++++++++++++++++++++++
    topmostSubform.Page1.JobSelect::initialize - (JavaScript, client)
    var sDataConnectionName = "BBCC"; // example - var sDataConnectionName
    = "Test";
    var sColHiddenValue = "ContractAdmin_Key"; // example - var
    sColHiddenValue = "Dept_ID";
    var sColDisplayText = "JobDescription"; // example - var
    sColDisplayText = "Dept_ID"
    // Search for sourceSet node which matchs the DataConnection name
    var nIndex = 0;
    while(xfa.sourceSet.nodes.item(nIndex).name != sDataConnectionName)
    nIndex++;
    var oDB = xfa.sourceSet.nodes.item(nIndex);
    oDB.open();
    oDB.first();
    // Search node with the class name "command"
    var nDBIndex = 0;
    while(oDB.nodes.item(nDBIndex).className != "command")
    nDBIndex++;
    // Backup the original settings before assigning BOF and EOF to stay
    var sBOFBackup =
    oDB.nodes.item(nDBIndex).query.recordSet.getAttribute("bofAction");
    var sEOFBackup =
    oDB.nodes.item(nDBIndex).query.recordSet.getAttribute("eofAction");
    oDB.nodes.item(nDBIndex).query.recordSet.setAttribute("stayBOF",
    "bofAction");
    oDB.nodes.item(nDBIndex).query.recordSet.setAttribute("stayEOF",
    "eofAction");
    // Clear the list
    this.clearItems();
    // Search for the record node with the matching Data Connection name
    nIndex = 0;
    while(xfa.record.nodes.item(nIndex).name != sDataConnectionName)
    nIndex++;
    var oRecord = xfa.record.nodes.item(nIndex);
    // Find the value node
    var oValueNode = null;
    var oTextNode = null;
    for(var nColIndex = 0; nColIndex < oRecord.nodes.length; nColIndex++)
    { if(oRecord.nodes.item(nColIndex).name == sColHiddenValue)
    { oValueNode = oRecord.nodes.item(nColIndex); } else
    if(oRecord.nodes.item(nColIndex).name == sColDisplayText) { oTextNode
    = oRecord.nodes.item(nColIndex); } }
    while(!oDB.isEOF())
      this.addItem(oTextNode.value, oValueNode.value);
       oDB.next();
    // Restore the original settings
    oDB.nodes.item(nDBIndex).query.recordSet.setAttribute(sBOFBackup,
    "bofAction");
    oDB.nodes.item(nDBIndex).query.recordSet.setAttribute(sEOFBackup,
    "eofAction");
    // Close connection
    oDB.close();
    ++++++++++++++++++++++
    Here is code for the refresh button
    +++++++++++++++++++++
    topmostSubform.Page1.Button27::click - (JavaScript, client)
    sourceSet.BBCC.requery();
    +++++++++++++++++++++

    pguerett wrote:
    The other thing that might be happening is a refresh issue on the DropDownList. Try adding the command xfa.layout.relayout() after the database connection has been closed.
    Paul
    Good catch Paul!  Would you believe that I have been trying to get this resolved for almost two years! Works perfect now.
    Thank you,
      - Eric

  • EXPDP and IMPDP from existing database to new 'scratch' database

    Hi All,
    THis is the first time i'm trying to export and import (using datapump) from one database into a brand spanking new database.
    Source/Target OS - WIndows 2008 R2 Standard
    Source/Target - Oracle 11G Release 2 (same patch updates - 11.2.0.3.3)
    I took a full expd of the source database.
    I created the same directory structure on the target as the source. I created an empty database on the target server with the same name as the source.
    I am trying to use impdp to import this full export into the target database, with the end goal being everything is the same on the target as it is on the source (users, tablespaces, data, schemas, etc...).
    I am running into some errors (object already exists, a few others to mention). But my question is, is this a proper way of copying a database from one server to a new server?
    Thanks in advance

    Thanks, here are some of the errors i've received:
    ORA-31684: Object type ROLE:"HS_ADMIN_EXECUTE_ROLE" already exists
    ORA-39111: Dependent object type OBJECT_GRANT:"ORDDATA" skipped, base object type SEQUENCE:"ORDDATA"."ORDDCM_DICT_A_DA_ID_SEQ" already exists
    ORA-39082: Object type TRIGGER:"M_SYS"."MVP_OPD_D_TRG" created with compilation warnings
    Cannot set an SCN larger than the current SCN. If a Streams Capture configuration was imported then the Apply that processes the captured messages needs to be dropped and recreated. See My Oracle Support article number 1380295.1.Table "SYSTEM"."DEF$_DEFAULTDEST" exists. Data will be appended to existing table but all dependent metadata will be skipped due to table_exists_action of append
    ORA-31693: Table data object "SYSMAN"."MGMT_SYSTEM_PERFORMANCE_LOG" failed to load/unload and is being skipped due to error:
    ORA-29913: error in executing ODCIEXTTABLEFETCH callout
    ORA-02291: integrity constraint (SYSMAN.MGMT_SYSTEM_PERFORMANCE_LOG_FK) violated - parent key not found
    ORA-31693: Table data object "ORDDATA"."ORDDCM_DOCS" failed to load/unload and is being skipped due to error:
    ORA-29913: error in executing ODCIEXTTABLEFETCH callout
    ORA-00001: unique constraint (ORDDATA.ORDDCM_DOCS_PK) violated
    ORA-39082: Object type TRIGGER:"M_SYS"."M_US_PRIVS_TRG" created with compilation warnings
    ...and then the logfile finishes with this:
    Job "SYS"."SYS_IMPORT_FULL_01" completed with 6542 error(s) at 12:56:31

  • Populate combobox2 From database WHERE combobox1.text = something

    I want to populate combobox2 from database WHERE combobox1.text = something. Here is the code I have and also I am using datable so I want to keep it that way
    private void cbCompany_SelectedIndexChanged(object sender, EventArgs e)
                this.cmpLocationTableAdapter.FillLocbyCmp(this.shahiemsDataSet.cmpLocation, cbCompany.SelectedText.ToString());
                cbLocation.DataSource = shahiemsDataSet.cmpLocation;

    The result is a blank combobox2(cbLocation).
    Hello,
    Did you mean that the combobox2 bound to the datatable cbLocation, but it didn't contain any item, right?
    If so, it seems that the method FillLocbyCmp didn't fill any data to that datatable, to troubleshoot this case, we need to check the following tips.
    1. Whether the database for that dataAdapter contains any data, and whether you connected to the right database.
    2. Whether that database could get any result filtering by that text value.
    3. Whether that method could get that datatable filt succeccfully.
    Since we could not get code about that FillLocbyCmp method, if possible, you could share them with us.
    Regards,
    Carl
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Populate List from Database (Very Strange Behaviour)

    Dear Fellows,
    I have developed a from which has two lists One for Major (say) and Other for Minor (say), thesr minors are based on the value of Major.
    Now I have developed this system on Windows XP Professional, Developer/2000 6i and Oracle 8i (release 8.1.7).
    Major list is populated from database and it shows all major values now using 'when_list_change' trigger the minor list is populated from the database based on the value of major list. Interestingly enough it is working fine without any problem.
    Now I have deployed the software to Windows 2000 Professional/Server (tried on both), Developer/2000 6i and Oracle 8.0.5, but strangly the lists are not working now. First list (major) is still working but the other dependent lists are not working.
    Another strange thing is that it populate the second list for one particular value (only at times).
    The logic is that I have used a program unit to which i am passing 'list element' and 'query' and call it for each list in the when-list-change trigge.
    Now its a very strange behaviour, I don't know what to do?
    Your cooperation will be highly appreciated.
    regards.

    rolrollerx wrote:
    Hi,
    I have Nokia N8 (a great phone, btw) with Symbian Anna. I wanted to download the maps. But the PC Ovi Suite is just busy forever, without downloading anything (I used Performance Monitor to find out it was doing nothing for hours).
    As I have unlimited data plan from my phone, I decided to try updating directly from the phone instead. It successfully downloaded the list of maps, but when I selected one of them
    "No Wi-Fi network available. Please configure a WiFi access point in the phone Internet destination settings."
    Why should I do that? I have a working connection on that phone (as evidenced by the successful download of the list of maps). So now, I am stuck. How can I download the maps?
    Well, the suggestion is there. Use a router.
    ‡Thank you for hitting the Blue/Green Star button‡
    N8-00 RM 596 V:111.030.0609; E71-1(05) RM 346 V: 500.21.009

  • Populate Livecycle PDF from mySQL database using PHP

    I'm trying to set up a database of loan agreements, where users will submit a form through Acrobat and their information will be stored in a mySQL database. Later, they can go back and download the PDF, which will be repopulated with their data in the mySQL db.
    I made the form in Livecycle Designer and submit the information through HTTP POST. I can easily get the information from the form into the database...my only problem is getting that information back out into the PDF.
    What would allow me to write back to the PDF, preferably using PHP? What kind of syntax would that require?
    Thanks!

    I have a vital form that clients fill out, which is passed to many people in the company along the workflow. The form is a Planner and we have in the following PDF, Word Doc..
    Well before, the Planner.pdf was originally created in Word, since most people have access to Word.. but evolved to a PDF form created from the Word Doc via Adobe LiveCycle Designer 8.0 w/ User Rights enabled so that the form could be filled out and saved using Adobe Reader.. which was a step better than Word.. being that it is free. But this needed to be easier and more to the point b/c some clients don't particularly like installing the latest version of Reader, even if you provide them the link. Nor do they like saving the form, filling the form, and attaching the form to send back.
    My goal is to have the client fill an HTML version of the form, submit and be done with it, but everyone in the workflow be able to easily receive the filled Planner as a PDF form.
    So some months ago I ran into this post Chris Trip, "Populate Livecycle PDF from mySQL database using PHP" #8, 22 Sep 2007 4:37 pm
    which uses the command line Win32 pdftk.exe to merge an FDF file into an existing PDF on the remote server, and serve this to whoever.
    My problem was with shared hosting and having the ability to use the Win32 pdftk.exe along with PHP which is predominantly used on Linux boxes. And we used a Linux box.
    so i created the following unorthodox method, which a client fills the HTML version of the Planner, all field values are INSERTED into a table in MySQL DB, I and all filled planners that have been filled by clients to date can be viewed from a repository page where an XML file is served up of the corresponding client, but someone would have to have Acrobat Professional, to import the form data from the XML file into a blank form.. altoughh this is simple for me.. I have the PHP file already created so that when a Planner is filled and client submits. >> the an email is sent to me with a table row from the repository of the client name, #, email, and a link to d-load the XML file,
    But I also have the PHP files created so that the Planner can be sent to by email to various people in the workflow with certain fileds ommitted they they do not need to see, but instead of the XML file beiong served up i need the filled PDF Planner to be served.
    I can do this locally with ease on a testing server, but I am currently trying to use another host that uses cross-platform compatibility so i can use PHP and the pdftk.exe to achieve this, as that is why I am having to serve up an XML file b/c we use a Linux server for our website, and cant execute the exe.
    Now that I am testing the other server (cross-platform host), just to use them to do the PDF handling (and it's only $5 per month) I am having problems with getting READ, WRITE, EXECUTE permissions..
    Si guess a good question to ask is can PHP do the same procedure as the pdftk.exe, and i can eleminate it.
    or how in the heck can i get this data from the DB into a blank PDF form, like i have described??
    here are some link to reference
    Populating a LiveCycle PDF with PHP and MySQL
    http://www.andrewheiss.com/Tutorials?page=LiveCycle_PDFs_and_MySQL
    HTML form that passed data into a PDF
    http://www.mactech.com/articles/mactech/Vol.20/20.11/FillOnlinePDFFormsUsingHTML/index.htm l
    and an example
    http://accesspdf.com/html_pdf_form/

  • Building a JTree from a Database

    Hi everyone,
    I'm sort of new to Java. 3 months and still struggling.
    My challenge is I would like to populate a tree from a Database. The problem is I do not know in advance how many children, children and children a node will have. There could be none or many.
    For sure I'm able to build the root of the table and the involved folders both are coming from a database. The tables for this are like the following.
    -root table-
    root_id
    root_name
    -folders table-
    folder_id
    folder_name
    Now each folder, and there are at least one can have children and the children could have children and so on. This is more or less infinit. Here is the children table
    -folder_contents-
    content_id
    content_name
    content_folder_id
    parent_id
    A record might look like this where the parent it is a record in the same table
    1, 1.0, 1, null
    2, 1.1, 1, 1
    3, 1.2, 1, 2
    4, 2.0, 1, null
    3, 2.1, 1, 4
    and so on
    Some insight or code snippet would be highly appreciated and rewarded with Duke Dollars
    Thanks Oscar

    Hope this helps
    http://forum.java.sun.com/thread.jsp?forum=57&thread=118604
    http://forum.java.sun.com/thread.jsp?forum=57&thread=149431
    http://forum.java.sun.com/thread.jsp?forum=57&thread=121264

  • Pulling Parameters from SQL Database

    This is probably something simple that I'm missing, but I'm new to CR.
    I have a report where I am trying to populate a parameter value from a database field...how do I do this?
    I do not want the end user to have to enter this parameter.
    The parameter (database value) changes on a regular basis.
    More Detailed Explination:
    Report executes a SQL stored procedure with declared variable data.  This particular report is looking for a startdate and enddate.  There is a seperate table which is populated with these values - ONLY ONE RECORD called mindate and maxdate.
    I need CR to set parameter.startdate=SQLtable.mindate and parameter.enddate=SQLtable.maxdate, and then pass this to the stored procedure.
    Thanks for your help.

    What you want to do is pretty simple...
    Add a new SQL command to your data source list. Sometime like this...
    SELECT DISTINCT DateField FROM TableName ORDER BY DateField
    There is no need to link the new command to the SP... It is only there to provide the list of values for your prompt.
    Then choose Edit on your parameters... Where it says List of Values:, change it from Static to Dynamic.
    Where it says Click here to add item under Value, find the new command and choose the DateField.
    That said... why would you want to take that option with a date parameter? If time stamps are included in the DateField, your list of values is going to be HUGE... Why not just set the Type to Date and let the users just use the date picker???
    HTH,
    Jason

  • Removing Data from a Database using JList

    Hi,
    I have the following JList with a "Remove" button.
    I have managed to populate the JList with entries from the DataBase but now i am having problems removing the data from the data base using the JList.
    What i am trying to achieve is, when an entry is selected from the JList and the "Remove" button is hit, the entry should be removed from the JList and from the database.
    How do i do this, please help..
    import java.awt.*;
    import java.awt.event.*;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    import javax.swing.*;
    public class RemoveD extends JDialog {
        private JList list;
        private JButton removeButton;
        private JScrollPane scrollPane;
        private Connection conn = null;
        private Statement stat = null;
        private ResultSet rs = null;
        String names = new String();
        private DefaultListModel listModel = new DefaultListModel();
        public RemoveD(Frame parent, boolean modal) {
            super(parent, modal);
            initComponents();
        private void initComponents() {
            try {
                Class.forName("com.mysql.jdbc.Driver");
            } catch (ClassNotFoundException ex) {
                ex.printStackTrace();
            try {
                String userID = "";
                String psw = "";
                String url;
                url = "jdbc:mysql://localhost:3306/mqnames";
                conn = DriverManager.getConnection(url, userID, psw);
                stat = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
                        ResultSet.CONCUR_READ_ONLY);
                rs = stat.executeQuery("SELECT queueName FROM queuenametable");
                int j = 0;
                while (rs.next()) {
                    names = rs.getString(1);
                    System.out.println("rs: " + names);
                    listModel.addElement(names);
                }//end of While
                stat.close();
                conn.close();
            } catch (SQLException ex) {
                ex.printStackTrace();
            scrollPane = new JScrollPane();
            list = new JList(listModel);
            list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
            removeButton = new JButton();
            setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
            getContentPane().setLayout(new GridLayout(2, 0));
            scrollPane.setViewportView(list);
            getContentPane().add(scrollPane);
            removeButton.setText("Remove");
            removeButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    removeButtonActionPerformed(evt);
            getContentPane().add(removeButton);
            pack();
        private void removeButtonActionPerformed(ActionEvent evt) {
        public static void main(String args[]) {
            EventQueue.invokeLater(new Runnable() {
                public void run() {
                    RemoveD dialog = new RemoveD(new JFrame(), true);
                    dialog.addWindowListener(new WindowAdapter() {
                        public void windowClosing(WindowEvent e) {
                            System.exit(0);
                    dialog.setVisible(true);
    }

    Ask a specific question. Do you know how to get the selected item in the list? Do you know how to write a delete query in SQL?

Maybe you are looking for

  • How to create a report of email subscribers

    Hello This seems like a simple thing, but I've searched the forums and tried a few things in admin but can't work this out! I have a very simple online form on my website with 'name' and 'email' - it is a newsletter subscribe box. I would like to pro

  • In PL-SQL archive data from a table to a file

    I am currently developing a vb app where I need to archive data from a table to a file. I was hoping to do this with a stored procedure. I will also need to be able to retrieve the data from the file for future use if necessary. What file types are a

  • To import photos from Iphone to mac is a strange thing.

    There are different ways to import the Iphone pictures to the mac but the result is a strange thing. 1. way over the osx tool digital pictures. result with osx Lion 1.1 GB (with the osx Lion it is 3.8 GB with the same Iphone and pictures) 2. way with

  • Change labels in print menu from address book

    I am trying to print invitation labels from my address book for a personal party. I would like to change the labels in the print menu to add "and guest" or "and family". I called Mac support but they couldn't help me. Does anyone know how to manipula

  • 6i to 9i conversion OLE container stored in a LONG RAW column to BLOB

    I need to automate the migration of data stored in a long raw column to a blob column. The objects were stored in the long raw column using an Oracle Forms 6i OLE container. There is also multiple object types stored in the column, ie (word, excel, i