Simple Example, I Need Help!

I'm working on a very simple application using Eclipse and MySQL here it is:
http://img.photobucket.com/albums/v335/shlumph/table.jpg
It's pretty self-explanitory. You enter a person's first and last name, press submit, and their name flops onto the table. I made this naively, and do not know how to make use of reflection and beans, if that's even what I need.
I tried googling on how to make use of reflection and beans when dealing with database connectivity, but there's just so much different kinds of information, it's like trying to find a needle in a haystack.
If someone could help point me in a direction to go, post some in depth tutorials, or even point out a good book that I can get on amazon, that would be excellent!
Just incase if you care what I have done naively, here is the database structure and code:
I have a database named addressbook with a table called names. Inside of names there are the following columns:
first_name varchar(20)
last_name varchar(20)
public class example extends Composite {
     private Label firstNameLbl = null;
     private Text firstNameTxt = null;
     private Label lastNameLbl = null;
     private Text lastNameTxt = null;
     private Composite tableComposite = null;
     private Button submitButton = null;
     private Table nameTable = null;
     private Connection con = null;
     public example(Composite parent, int style) {
          super(parent, style);
          initialize();
     }//example()
     private void initialize() {
          GridData gridData1 = new GridData();
          gridData1.widthHint = 75;
          GridLayout gridLayout = new GridLayout();
          gridLayout.numColumns = 2;
          firstNameLbl = new Label(this, SWT.NONE);
          firstNameLbl.setText("First Name");
          firstNameTxt = new Text(this, SWT.BORDER);
          lastNameLbl = new Label(this, SWT.NONE);
          lastNameLbl.setText("Last Name");
          lastNameTxt = new Text(this, SWT.BORDER);
          this.setLayout(gridLayout);
          Label filler1 = new Label(this, SWT.NONE);
          submitButton = new Button(this, SWT.NONE);
          submitButton.setText("Submit");
          submitButton.setLayoutData(gridData1);
          submitButton
                    .addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
                         public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
                              getConnection();
                              try {
                                   String firstName = firstNameTxt.getText();
                                   String lastName = lastNameTxt.getText();
                                   String sql = "INSERT names VALUES ('" + firstName + "', '" + lastName + "')";
                                   Statement stmt = con.createStatement();
                                   stmt.executeUpdate(sql);
                                   //Update the table
                                   nameTable.removeAll();
                                   addItems();
                                   //Close connections
                                   con.close();
                                   stmt.close();
                              } catch (SQLException e2) {
                                   e2.printStackTrace();
                         }//widgetSelected()
          createTableComposite();
          this.setSize(new Point(241, 220));
     }//initialize()
      * This method initializes tableComposite     
     private void createTableComposite() {
          GridData gridData2 = new GridData();
          gridData2.widthHint = 200;
          gridData2.heightHint = 100;
          GridData gridData = new GridData();
          gridData.horizontalSpan = 2;
          tableComposite = new Composite(this, SWT.NONE);
          tableComposite.setLayout(new GridLayout());
          tableComposite.setLayoutData(gridData);
          nameTable = new Table(tableComposite, SWT.BORDER);
          nameTable.setHeaderVisible(true);
          nameTable.setLayoutData(gridData2);
          nameTable.setLinesVisible(true);
          TableColumn firstNameCol = new TableColumn(nameTable, SWT.LEFT);
          firstNameCol.setText("First Name");
          firstNameCol.setWidth(100);
          TableColumn lastNameCol = new TableColumn(nameTable, SWT.LEFT);
          lastNameCol.setText("Last Name");
          lastNameCol.setWidth(100);
          getConnection();
          addItems();
     }//createTableComposite()
      * This gets the MySQL Connection
     public void getConnection() {
          try {
           Class.forName("com.mysql.jdbc.Driver").newInstance();
           con = DriverManager.getConnection("jdbc:mysql:///addressbook", "root", "password");
         } catch(Exception e) {
           System.err.println("Exception: " + e.getMessage());
     }//getConnection()
      * This adds items to the address table
     private void addItems() {
          try {
               String sql = "SELECT first_name, last_name FROM names";
               Statement stmt = con.createStatement();
               ResultSet rs = stmt.executeQuery(sql);
               while(rs.next()) {
                    String first_name = rs.getString(1);
                    String last_name = rs.getString(2);
                    String[] row = new String[]{first_name, last_name};
                    TableItem item1 = new TableItem(nameTable, 0);
                    item1.setText(row);
          } catch (SQLException e) {
               e.printStackTrace();
     }//addItems()
} Message was edited by:
shlumph

Yes, the id column is auto-increment and not null. I
kind of went on a rampage without reading your latter
post and added some more stuff.So tell me why I bothered?
I added in other columns: street, city, state, phone
and email to my database. As well as
fields/setters/getters to my Person class.What does adding more columns do when you can't even insert what you had? Seems foolish. Do the easy thing first, then expand.
I think I went on a different, but similar route then
what you mentioned with the database utility. Mine's the right way. 8)
I
tried making a MySQL generator
interface/implementation along with a PersonDao
interface/implementation, like you mentioned.
Can you give me some more suggestions, I'm sure this
is done noobly/poorly.I like that find idiom for method names. Why did you copy the interface I gave you and add "search"? The idea would be to add find methods that have different parameters. In your case, I'd have a find that takes two String arguments.
It's not just being picky. Consistency matters. If you published this, a user would be likely to think "Why two find methods and a search? Did two people write this?" Pick one and stick to it.
It's great, except for that search method. After all, it's what I gave you.
>
To give you an example, here is my implementation for
methods delete, and find:
     public void delete(Person p) {
          mysql.delete("names", "id", p.getID().toString());
     public Person find(Long id) {
          Person p = new Person();
ResultSet rs = mysql.find("names", "id",
", id.toString());
          try {
               while (rs.next()) {
                    String firstName = rs.getString(1);
                    String lastName = rs.getString(2);
                    String street = rs.getString(4);
                    String city = rs.getString(5);
                    String state = rs.getString(6);
                    String zipCode = rs.getString(7);
                    String phone = rs.getString(8);
                    String email = rs.getString(9);
                    p.setID(id);
                    p.setFirstName(firstName);
                    p.setLastName(lastName);
                    p.setStreet(street);
                    p.setCity(city);
                    p.setState(state);
                    p.setZipCode(zipCode);
                    p.setPhone(phone);
                    p.setEmail(email);;
          } catch (SQLException e) {
               e.printStackTrace();
          mysql.closeConnection();
          return p;
     }// find()Here is my MySqlGenerator interface:
public interface MySqlGenerator {
     public ResultSet selectAll(String table);
public ResultSet find(String table, String pkColumn,
, String pkValue);
public ResultSet search(String table, String column,
, String search);
public List<Object> select(String table, String
g column);
public void update(String table, String column,
, String pkColumn, String pkValue, String newValue);
public void save(String table, String column, String
g values);
public void delete(String table, String pkColumn,
, String pkValue);
     public void closeConnection();
}And to give you an example, here is the
implementation for delete and find:
public void delete(String table, String pkColumn,
, String pkValue) {
          getConnection();
          try {
               Statement stmt = con.createStatement();
String sql = "DELETE FROM " +table+ " WHERE "
E " +pkColumn+ "=" + pkValue;
               stmt.executeUpdate(sql);
          } catch (SQLException e) {
               e.printStackTrace();
          } finally {
               closeConnection();
public ResultSet find(String table, String pkColumn,
, String pkValue) {
          getConnection();
          ResultSet rs = null;
          try {
               Statement stmt = con.createStatement();
String sql = "SELECT * FROM" +table+ " WHERE "
E " +pkColumn+ "=" + pkValue;
               rs = stmt.executeQuery(sql);
          } catch (SQLException e) {
               e.printStackTrace();
          return rs;
     }So theoretically, if this was done well (which I'm
sure it's not), I could put PersonDao, PersonDaoImpl,
MySqlGenerator, MySqlGeneratorImpl, all into a
package named persistence?I don't see what that MySqlGenerator is all about.
No, I wouldn't recommend doing it this way. Put it all the in the PersonDaoImpl. Better yet, create a subpackage "jdbc" under persistence and put the PersonDaoImpl in there. JDBC is one way to implement this interface. There are lots of others. But this is what you should do to start.
NEVER return a ResultSet from a method that way. Load the contents into an object or data structure and close it inside the method that created it. You're leaking a database cursor that way, AND you're exposing SQL stuff to clients. Keep all the persistence artifacts inside the persistence package. Don't let them leak out that way.
Nope, sorry, I don't think this is it.
%

Similar Messages

  • Trying to create a simple example. Need Help!

    I'm trying to create a very simlpe examlpe using Swing components to illustrate a MVC architecture.
    I have a JFrame containing a JTree and a JButton.
    What I'd like to happen is when I click the JButton the JTree model is changed in some fashion and the the view is refreshed due to the models change.
    If anyone out there has a simple example of any MVC architecture involving Swing components I'd love to see it.
    Thx

    Sure, look at any of the Sun tutorials. For example, look in your API documentation for JTree; it has a link to a tutorial about how to use JTree.

  • OLAP ... Adobe example used; need help fixing a bug (clearing variables on error)

    Okay ...
    So I used one of the Adobe examples except now it's part of a container and it's using a datasource instead of the flatfile the example uses.  Also, for some reason I need to create a button instead of using the creationComplete to get it to work.  My problem is if the button is clicked to fast while it's loading the data (since another part of the application has a dropdown menu so you can requery information) you get an error and for some reason, you'll still get the same error even if the data is fully loaded and even if you change the parameter to reload the data.  My feeling is that the variables are not getting cleared out after it throws the error.
    So my question is what is the best way to clear out the variables (and how) when it throws an error.  The code for the page is below.
    Joe
    <?xml version="1.0" encoding="utf-8"?>
    <v:MaxRestorePanel xmlns:mx="http://www.adobe.com/2006/mxml"
        xmlns:v="views.*"
        layout="vertical"
        creationComplete="creationCompleteHandler3();">
        <mx:Script>
          <![CDATA[
            import mx.collections.ICollectionView;
            import mx.rpc.AsyncResponder;
            import mx.rpc.AsyncToken;
            import mx.olap.OLAPQuery;
            import mx.olap.OLAPSet;
            import mx.olap.IOLAPQuery;
            import mx.olap.IOLAPQueryAxis;
            import mx.olap.IOLAPCube;
            import mx.olap.OLAPResult;
            import mx.events.CubeEvent;
            import mx.controls.Alert;
            import mx.collections.ArrayCollection;
            [Bindable]
            public var dp:ICollectionView = null;
            // Format of Objects in the ArrayCollection:
            //  data:Object = {
            //    customer:"AAA",
            //    product:"ColdFusion",
            //    quarter:"Q1"
            //    revenue: "100.00"
            private function creationCompleteHandler3():void {
                // You must initialize the cube before you
                // can execute a query on it.
                myMXMLCube3.refresh();
            // Create the OLAP query.
            private function getQuery(cube:IOLAPCube):IOLAPQuery {
                // Create an instance of OLAPQuery to represent the query.
                var query:OLAPQuery = new OLAPQuery;
                // Get the row axis from the query instance.
                var rowQueryAxis:IOLAPQueryAxis =
                    query.getAxis(OLAPQuery.ROW_AXIS);
                // Create an OLAPSet instance to configure the axis.
                var productSet:OLAPSet = new OLAPSet;
                // Add the Product to the row to aggregate data
                // by the Product dimension.
                productSet.addElements(
                    cube.findDimension("ProductDim").findAttribute("Product").children);
                // Add the OLAPSet instance to the axis.
                rowQueryAxis.addSet(productSet);
                // Get the column axis from the query instance, and configure it
                // to aggregate the columns by the Quarter dimension.
                var colQueryAxis:IOLAPQueryAxis =
                    query.getAxis(OLAPQuery.COLUMN_AXIS);        
                var quarterSet:OLAPSet= new OLAPSet;
                quarterSet.addElements(
                    cube.findDimension("QuarterDim").findAttribute("HLMC").children);
                colQueryAxis.addSet(quarterSet);
                return query;      
            // Event handler to execute the OLAP query
            // after the cube completes initialization.
            private function runQuery(event:CubeEvent):void {
                // Get cube.
                var cube:IOLAPCube = IOLAPCube(event.currentTarget);
                // Create a query instance.
                var query:IOLAPQuery = getQuery(cube);
                // Execute the query.
                var token:AsyncToken = cube.execute(query);
                // Setup handlers for the query results.
                token.addResponder(new AsyncResponder(showResult, showFault));
            // Handle a query fault.
            private function showFault(result:Object, token:Object):void {
                Alert.show("Error in query.");
            // Handle a successful query by passing the query results to
            // the OLAPDataGrid control..
            private function showResult(result:Object, token:Object):void {
                if (!result) {
                    Alert.show("No results from query.");
                    return;
                myOLAPDG3.dataProvider= result as OLAPResult;           
          ]]>
        </mx:Script>
        <mx:OLAPCube name="FlatSchemaCube" dataProvider="{dp}" id="myMXMLCube3" complete="runQuery(event);">
            <mx:OLAPDimension name="CustomerDim">
                <mx:OLAPAttribute name="Customer" dataField="TITLE_NAME"/>
                <mx:OLAPHierarchy name="CustomerHier" hasAll="true">
                    <mx:OLAPLevel attributeName="Customer"/>
                </mx:OLAPHierarchy>
            </mx:OLAPDimension>
            <mx:OLAPDimension name="ProductDim">
                <mx:OLAPAttribute name="Product" dataField="CORP_SITE"/>
                <mx:OLAPHierarchy name="ProductHier" hasAll="true">
                    <mx:OLAPLevel attributeName="Product"/>
                </mx:OLAPHierarchy>
            </mx:OLAPDimension>
            <mx:OLAPDimension name="QuarterDim">
                <mx:OLAPAttribute name="HLMC" dataField="HLMC"/>
                <mx:OLAPHierarchy name="QuarterHier" hasAll="true">
                    <mx:OLAPLevel attributeName="HLMC"/>
                </mx:OLAPHierarchy>
            </mx:OLAPDimension>
            <mx:OLAPMeasure name="Revenue"
                dataField="CUR_YR_1"
                aggregator="SUM"/>
        </mx:OLAPCube>
             <mx:OLAPDataGrid id="myOLAPDG3" defaultCellString="-" textAlign="right" color="0x323232" width="100%" height="100%"/>
            <mx:ControlBar id="controls">       
            <mx:Button label="Pull Details" click="creationCompleteHandler3();"/>
            </mx:ControlBar>
    </v:MaxRestorePanel>

    Okay ...
    So I used one of the Adobe examples except now it's part of a container and it's using a datasource instead of the flatfile the example uses.  Also, for some reason I need to create a button instead of using the creationComplete to get it to work.  My problem is if the button is clicked to fast while it's loading the data (since another part of the application has a dropdown menu so you can requery information) you get an error and for some reason, you'll still get the same error even if the data is fully loaded and even if you change the parameter to reload the data.  My feeling is that the variables are not getting cleared out after it throws the error.
    So my question is what is the best way to clear out the variables (and how) when it throws an error.  The code for the page is below.
    Joe
    <?xml version="1.0" encoding="utf-8"?>
    <v:MaxRestorePanel xmlns:mx="http://www.adobe.com/2006/mxml"
        xmlns:v="views.*"
        layout="vertical"
        creationComplete="creationCompleteHandler3();">
        <mx:Script>
          <![CDATA[
            import mx.collections.ICollectionView;
            import mx.rpc.AsyncResponder;
            import mx.rpc.AsyncToken;
            import mx.olap.OLAPQuery;
            import mx.olap.OLAPSet;
            import mx.olap.IOLAPQuery;
            import mx.olap.IOLAPQueryAxis;
            import mx.olap.IOLAPCube;
            import mx.olap.OLAPResult;
            import mx.events.CubeEvent;
            import mx.controls.Alert;
            import mx.collections.ArrayCollection;
            [Bindable]
            public var dp:ICollectionView = null;
            // Format of Objects in the ArrayCollection:
            //  data:Object = {
            //    customer:"AAA",
            //    product:"ColdFusion",
            //    quarter:"Q1"
            //    revenue: "100.00"
            private function creationCompleteHandler3():void {
                // You must initialize the cube before you
                // can execute a query on it.
                myMXMLCube3.refresh();
            // Create the OLAP query.
            private function getQuery(cube:IOLAPCube):IOLAPQuery {
                // Create an instance of OLAPQuery to represent the query.
                var query:OLAPQuery = new OLAPQuery;
                // Get the row axis from the query instance.
                var rowQueryAxis:IOLAPQueryAxis =
                    query.getAxis(OLAPQuery.ROW_AXIS);
                // Create an OLAPSet instance to configure the axis.
                var productSet:OLAPSet = new OLAPSet;
                // Add the Product to the row to aggregate data
                // by the Product dimension.
                productSet.addElements(
                    cube.findDimension("ProductDim").findAttribute("Product").children);
                // Add the OLAPSet instance to the axis.
                rowQueryAxis.addSet(productSet);
                // Get the column axis from the query instance, and configure it
                // to aggregate the columns by the Quarter dimension.
                var colQueryAxis:IOLAPQueryAxis =
                    query.getAxis(OLAPQuery.COLUMN_AXIS);        
                var quarterSet:OLAPSet= new OLAPSet;
                quarterSet.addElements(
                    cube.findDimension("QuarterDim").findAttribute("HLMC").children);
                colQueryAxis.addSet(quarterSet);
                return query;      
            // Event handler to execute the OLAP query
            // after the cube completes initialization.
            private function runQuery(event:CubeEvent):void {
                // Get cube.
                var cube:IOLAPCube = IOLAPCube(event.currentTarget);
                // Create a query instance.
                var query:IOLAPQuery = getQuery(cube);
                // Execute the query.
                var token:AsyncToken = cube.execute(query);
                // Setup handlers for the query results.
                token.addResponder(new AsyncResponder(showResult, showFault));
            // Handle a query fault.
            private function showFault(result:Object, token:Object):void {
                Alert.show("Error in query.");
            // Handle a successful query by passing the query results to
            // the OLAPDataGrid control..
            private function showResult(result:Object, token:Object):void {
                if (!result) {
                    Alert.show("No results from query.");
                    return;
                myOLAPDG3.dataProvider= result as OLAPResult;           
          ]]>
        </mx:Script>
        <mx:OLAPCube name="FlatSchemaCube" dataProvider="{dp}" id="myMXMLCube3" complete="runQuery(event);">
            <mx:OLAPDimension name="CustomerDim">
                <mx:OLAPAttribute name="Customer" dataField="TITLE_NAME"/>
                <mx:OLAPHierarchy name="CustomerHier" hasAll="true">
                    <mx:OLAPLevel attributeName="Customer"/>
                </mx:OLAPHierarchy>
            </mx:OLAPDimension>
            <mx:OLAPDimension name="ProductDim">
                <mx:OLAPAttribute name="Product" dataField="CORP_SITE"/>
                <mx:OLAPHierarchy name="ProductHier" hasAll="true">
                    <mx:OLAPLevel attributeName="Product"/>
                </mx:OLAPHierarchy>
            </mx:OLAPDimension>
            <mx:OLAPDimension name="QuarterDim">
                <mx:OLAPAttribute name="HLMC" dataField="HLMC"/>
                <mx:OLAPHierarchy name="QuarterHier" hasAll="true">
                    <mx:OLAPLevel attributeName="HLMC"/>
                </mx:OLAPHierarchy>
            </mx:OLAPDimension>
            <mx:OLAPMeasure name="Revenue"
                dataField="CUR_YR_1"
                aggregator="SUM"/>
        </mx:OLAPCube>
             <mx:OLAPDataGrid id="myOLAPDG3" defaultCellString="-" textAlign="right" color="0x323232" width="100%" height="100%"/>
            <mx:ControlBar id="controls">       
            <mx:Button label="Pull Details" click="creationCompleteHandler3();"/>
            </mx:ControlBar>
    </v:MaxRestorePanel>

  • A few simple questions i need help on please

    i have an ipod mini. my computer crashed and i have a new computer. is there a way to upload my songs and lists to the computer? i have itunes 7.0.
    second question. is there a way to upload only one or two songs to an ipod mini that is already loaded with songs, without uploading all the songs again. is the current info automatically overwritten so that i would end up with only the two songs on the ipod after uploading?
    thanks in advance.
    bob

    is there a way to upload my songs and lists to the computer?
    Maybe. You say your old computer crashed. Does that mean it doesn't run at all? Does it mean it hangs during the boot-up process? Does it mean the hard drive came to a crashing screeching halt? Without knowing more about the death of the old computer none of us can know whether the data is recoverable or not.
    OTOH, you have at least part of your music data on your iPod. So with the help of third party software (check out your favorite download site) you'll be able to transfer your iPod's music and playlists to the new computer. If the iPod contains your entire music collection you are pretty much good to go.
    Can you add only a couple songs to your iPod? Sure, after connecting it to your new computer you'll be told it is synced to another computer and asked if you want to sync it to this new one. Select cancel - no you don't want to sync it to the new one. After the iPod appears in iTunes select it and in the iPod preferences select manually manage. This will let you manually add or delete songs.

  • Need help with a very simple example.  Trying to reference a value

    Im very new to Sql Load and have created this very simple example of what I need to do.
    I just want to reference the ID column from one table to be inserted into another table as DEV_ID.
    Below are my: 1) Control File, 2) Datafile, 3) Table Description, 4) Table Description
    1) CONTROL FILE:
    LOAD DATA
    INFILE 'test.dat'
    APPEND
    INTO TABLE p_ports
    FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
    DEV_id REF(CONSTANT 'P_DEVICES',NAME),
    NAME FILLER ,
    PORT_NO
    2) DATAFILE:
    COMM881-0326ES09,6
    3) TABLE DESCRIPTION:
    SQL> describe p_ports
    Name Null? Type
    ID NOT NULL NUMBER(10)
    DEV_ID NOT NULL NUMBER(10)
    PORT_NO     NUMBER(3)

    hi,
    i managed to do this for my app. (think i referred to viewTransitions sample code and modified quite a bit)
    i can't remember this well cos i did this quite a while back, but i will try to help as much as possible
    1) from the appdelegate i initialize a root controller (view controller class)
    2) this root controller actually contains two other view controllers, let's call it viewAController and viewBController, for the screens which u are going to toggle in between. and there's also a function, let's call it toggleMenu, which will set the menus to and fro. i copied this whole chunk from the sample code. it actually defines the code on what to do, i.e. if current view is A switch to B and vice versa.
    3) inside the controller files, you need to implement the toggleMenu function too, which basically calls the rootController's toggleMenu
    4) we also need viewA and viewB files(view class)
    5) need to add the .xib files for the respective views and link them up to the controller class. i did not use the .xib files for ui layout though, because of my app's needs. however, it will not work properly without the .xib files.
    5) inside the view class of both views, i.e. viewA.m and viewB.m, you need to create a button, that will call the toggleMenu function inside the respective controller class.
    it will look something like this:
    [Button addTarget:ViewAController action:@selector(toggleMenu:) forControlEvents:UIControlEventTouchUpInside];
    so the flow is really button (in view)-> toggleMenu(viewController) -> toggleMenu(rootController)
    i'm sorry it sounds pretty hazy, i did this part weeks before and can't really remember. i hope it helps.

  • Need help with a simple process with FTP Adapter and File Adapter

    I am trying out a simple BPEL process that gets a file in opaque mode from a FTP server using a FTP adapter and writes it to the local file system using a File Adapter. However, the file written is always empty (zero bytes). I then tried out the FTPDebatching sample using the same FTP server JNDI name and this work fine surprisingly. I also verified by looking at the FTP server logs that my process actually does hit the FTP server and seems to list the files based on the filtering condition - but it does not issue any GET or RETR commands to actually get the files. I am suspecting that the problem could be in the Receive, Assign or Invoke activities, but I am not able identify what it is.
    I can provide additional info such as the contents of my bpel and wsdl files if needed.
    Would appreciate if someone can help me with this at the earliest.
    Thanks
    Jay

    persiandude wrote:
    Topic: Need help with if, else, and which statements and loops.
    How would I display 60 < temp. <= 85 in java
    System.out.println("60 < temp. <= 85 in java");
    another question is how do I ask a question like want to try again (y/n) after a output and asking that everytime I type in yes after a output and terminate when saying No.Sun's [basic Java tutorial|http://java.sun.com/docs/books/tutorial/]
    Sun's [New To Java Center|http://java.sun.com/learning/new2java/index.html].Includes an overview of what Java is, instructions for setting up Java, an intro to programming (that includes links to the above tutorial or to parts of it), quizzes, a list of resources, and info on certification and courses.
    [http://javaalmanac.com|http://javaalmanac.com]. A couple dozen code examples that supplement [The Java Developers Almanac|http://www.amazon.com/exec/obidos/tg/detail/-/0201752808?v=glance].
    jGuru. A general Java resource site. Includes FAQs, forums, courses, more.
    JavaRanch. To quote the tagline on their homepage: "a friendly place for Java greenhorns." FAQs, forums (moderated, I believe), sample code, all kinds of goodies for newbies. From what I've heard, they live up to the "friendly" claim.
    Bruce Eckel's [Thinking in Java|http://mindview.net/Books/DownloadSites] (Available online.)
    Joshua Bloch's [Effective Java|http://www.amazon.com/Effective-Java-2nd-Joshua-Bloch/dp/0321356683/ref=pd_bbs_1?ie=UTF8&s=books&qid=1214349768&sr=8-1]
    Bert Bates and Kathy Sierra's [Head First Java|http://www.amazon.com/exec/obidos/tg/detail/-/0596004656?v=glance].
    James Gosling's [The Java Programming Language|http://www.bookpool.com/sm/0321349806].

  • Need help making a simple script for my webcam

    Hey everyone, fairly new to applescript programming. I just bought a usb camera for my macbook because I use it for video conferencing/playing around, and it is better quality than the built in isight. However, in order to use this camera I need to use drivers from a program called camTwist. This being said camTwist needs to be opened first and the usb camera must be selected from camTwist Step 1 list in order for any other application to use the camera. I just want to make a simple program that would open camTwist first, then select "webcam" from the list (double click it like I always have to in order to select it) in order to activate the driver, and then open photo booth which would then be using the camTwist driver in order to take pictures.
    I made a crude program but it does not automatically select "webcam" from the Step 1 list in camTwist:
    tell application "CamTwist" to activate
    delay 10
    tell application "Photo Booth" to activate
    that’s basically it. I set the delay to 10 seconds so that when camTwists boots up first I can manually select my webcam. HOWEVER, I would like to make a script that would boot up CamTwist first, select my webcam from the list automatically, and then open Photo Booth with the CamTwist webcam driver already selected.
    Don't know much about applescript so any help to make a working script to solve my problem would be greatly appreciated! Thanks!

    Solved my problem but now I need help with something else! First I used CamTwist user options to create user defined hot keys with the specific purpose to load the webcam. I chose Command+B. I tested it out in CamTwist and it worked. The program follows a logical order from there. First it loads CamTwist, then after a short delay it presses the hot keys in order to load the webcam from the video source list, then another short delay and Photo Booth is opened with the driver loaded from camTwist. Everything works Perfect! Here's the code:
    tell application "System Events"
    tell application "CamTwist" to activate
    delay 0.5
    --Press command+b which is a user defined hot key to load webcam
    key code 11 using command down
    end tell
    delay 0.5
    tell application "Photo Booth" to activate
    My Next question is, would it be possible with this same script to have both applications quit together. For example I always quit Photo Booth first, so when I quit photo booth is there a way to make CamTwist also quit and keep everything within the same script? Please let me know. This forum has been very helpful and lead me to a solution to my problem! Hoping I can solve this next problem as well! Thanks everyone.

  • I need some simple examples to start with for Oracle ESB

    Hi All,
    Please share some simple examples to startwith for Oracle ESB.
    I need to understand, what are the files are created, once created an ESB project.
    What is the use of the files how to edit them with out using JDeveloper.
    Iam trying to create a simple example.
    I would like to create a file which has only "HELLO" in that file, simple text file inside a folder "INPUT" in my c:\ drive.
    I wanted to create a ESB service which picks up the file and add a string to it like "HELLO" + "ESB" and drop this file into "OUTPUT" folder in c:\ drive.
    How do i do that. I tried to do it when i deploy the integration server connection is gettting hit badly. I dont see that connection any more and i dont see that connection in my JDeveloper.
    I dont want to start with existing code.
    Please help
    Regards,
    Vijay.B
    Message was edited by:
    Vijay.B
    Message was edited by:
    Vijay.B

    Hi,
    If you want to do it from scratch you can basically do the following:
    Make sure you have created an application server and integration server connection in JDeveloper.
    1) Create a new JDeveloper project of type ESB project.
    2) Possibly add a ESB System/Group (open the esb file and click "Create System/Group") to group ESB projects.
    3) Create an XML schema describing your input XML file. Probably one element of type xsd:string.
    4) Create an example XML file which is well-formed and valid according to the XSD from step 3.
    5) Create a new File adapter (inbound/read). A routing service is automatically created.
    6) Create a new File adapter (outbound/write).
    7) Create a routing rule in the routing service in which you invoke the write method of the outbound file adapter. Possibly add a transformation using the XSL mapper.
    8) Deploy the ESB project to the server.
    9) Drop your XML file (from step 4) in the directory in which the inbound file adapter is polling.
    10) If it is ok, the file should be picked up, transformed and dropped in the outbound directory. A new ESB instance should be visible in the ESB console.
    See what files are generated on the filesystem in each of the above steps.
    Regards, Ronald

  • Need help with a simple program (should be simple anyway)

    I'm (starting to begin) writing a nice simple program that should be easy however I'm stuck on how to make the "New" button in the file menu clear all the fields. Any help? I'll attach the code below.
    ====================================================
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Message extends JFrame implements ActionListener {
         public void actionPerformed(ActionEvent evt) {
         text1.setText(" ");
         text2.setText("RE: ");
         text3.setText(" ");
         public Message() {
         super("Write a Message - by Kieran Hannigan");
         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         setSize(370,270);
         FlowLayout flo = new FlowLayout(FlowLayout.RIGHT);
         setLayout(flo);
         //Make the bar
         JMenuBar bar = new JMenuBar();
         //Make "File" on Menu
         JMenu File = new JMenu("File");
         JMenuItem f1 = new JMenuItem("New");f1.addActionListener(this);
         JMenuItem f2 = new JMenuItem("Open");
         JMenuItem f3 = new JMenuItem("Save");
         JMenuItem f4 = new JMenuItem("Save As");
         JMenuItem f5 = new JMenuItem("Exit");
         File.add(f1);
         File.add(f2);
         File.add(f3);
         File.add(f4);
         File.add(f5);
         bar.add(File);
         //Make "Edit" on menu
         JMenu Edit = new JMenu("Edit");
         JMenuItem e1 = new JMenuItem("Cut");
         JMenuItem e2 = new JMenuItem("Paste");
         JMenuItem e3 = new JMenuItem("Copy");
         JMenuItem e4 = new JMenuItem("Repeat");
         JMenuItem e5 = new JMenuItem("Undo");
         Edit.add(e5);
         Edit.add(e4);
         Edit.add(e1);
         Edit.add(e3);
         Edit.add(e2);
         bar.add(Edit);
         //Make "View" on menu
         JMenu View = new JMenu("View");
         JMenuItem v1 = new JMenuItem("Bold");
         JMenuItem v2 = new JMenuItem("Italic");
         JMenuItem v3 = new JMenuItem("Normal");
         JMenuItem v4 = new JMenuItem("Bold-Italic");
         View.add(v1);
         View.add(v2);
         View.add(v3);
         View.addSeparator();
         View.add(v4);
         bar.add(View);
         //Make "Help" on menu
         JMenu Help = new JMenu("Help");
         JMenuItem h1 = new JMenuItem("Help Online");
         JMenuItem h2 = new JMenuItem("E-mail Programmer");
         Help.add(h1);
         Help.add(h2);
         bar.add(Help);
         setJMenuBar(bar);
         //Make Contents of window.
         //Make "Subject" text field
         JPanel row2 = new JPanel();
         JLabel sublabel = new JLabel("Subject:");
         row2.add(sublabel);
         JTextField text2 = new JTextField("RE:",24);
         row2.add(text2);
         //Make "To" text field
         JPanel row1 = new JPanel();
         JLabel tolabel = new JLabel("To:");
         row1.add(tolabel);
         JTextField text1 = new JTextField(24);
         row1.add(text1);
         //Make "Message" text area
         JPanel row3 = new JPanel();
         JLabel Meslabel = new JLabel("Message:");
         row3.add(Meslabel);
         JTextArea text3 = new JTextArea(6,22);
         messagearea.setLineWrap(true);
         messagearea.setWrapStyleWord(true);
         JScrollPane scroll = new JScrollPane(text3,
                                  JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                                  JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
         //SpaceLine
         JPanel spaceline = new JPanel();
         JLabel spacer = new JLabel(" ");
         spaceline.add(spacer);
         row3.add(scroll);
         add(row1);
         add(row2);
         add(spaceline);
         add(spaceline);
         add(row3);
         setVisible(true);
         public static void main(String[] arguments) {
         Message Message = new Message();
    }

    persiandude wrote:
    Topic: Need help with if, else, and which statements and loops.
    How would I display 60 < temp. <= 85 in java
    System.out.println("60 < temp. <= 85 in java");
    another question is how do I ask a question like want to try again (y/n) after a output and asking that everytime I type in yes after a output and terminate when saying No.Sun's [basic Java tutorial|http://java.sun.com/docs/books/tutorial/]
    Sun's [New To Java Center|http://java.sun.com/learning/new2java/index.html].Includes an overview of what Java is, instructions for setting up Java, an intro to programming (that includes links to the above tutorial or to parts of it), quizzes, a list of resources, and info on certification and courses.
    [http://javaalmanac.com|http://javaalmanac.com]. A couple dozen code examples that supplement [The Java Developers Almanac|http://www.amazon.com/exec/obidos/tg/detail/-/0201752808?v=glance].
    jGuru. A general Java resource site. Includes FAQs, forums, courses, more.
    JavaRanch. To quote the tagline on their homepage: "a friendly place for Java greenhorns." FAQs, forums (moderated, I believe), sample code, all kinds of goodies for newbies. From what I've heard, they live up to the "friendly" claim.
    Bruce Eckel's [Thinking in Java|http://mindview.net/Books/DownloadSites] (Available online.)
    Joshua Bloch's [Effective Java|http://www.amazon.com/Effective-Java-2nd-Joshua-Bloch/dp/0321356683/ref=pd_bbs_1?ie=UTF8&s=books&qid=1214349768&sr=8-1]
    Bert Bates and Kathy Sierra's [Head First Java|http://www.amazon.com/exec/obidos/tg/detail/-/0596004656?v=glance].
    James Gosling's [The Java Programming Language|http://www.bookpool.com/sm/0321349806].

  • Need simple example of flex2 to webservice

    Hello,
    I understand that so long as you don't use remote objects,
    you don't have to buy the FDS! So how do I bypass using FDS and
    just use HTTPS or webservices?
    Can someone point me in the right direction with a
    good/simple example of using flex 2.0 with https and/or
    webservices?
    Thanks,
    K.

    OK - I finally get this.  I guess that SAP Business One is the entry level, least expensive license.  If my company buys SAP Business One, will that provide the R/3 system and BAPIs to build some demos?  And can I hook up SAP Business One to the Sneak Preview SAP NewWeaver 6.40 in order to invoke the BAPIs using Java?
    And I guess that if we buy SAP Busienss One, then I don't need 6.40 ABAP stack to invoke the BAPIS - or do I?
    Thanks for your help.

  • Need Simple Example of Notifier and Occurance

    hi friends
    i need to know the exact funtion of notifiers and occurances. So can you send me the simple example for both..
    Thanks in advance... 

    Open your example finder (help..find examples...") and search for these two terms.
    I recommend looking at "General Notifier example.vi" and "Generate Occurrences.vi".
    Is there anything in the online help that is not clear? What are you trying to do?
    Message Edited by altenbach on 09-26-2008 11:22 PM
    LabVIEW Champion . Do more with less code and in less time .

  • I need for a simple example of  reading a xml file using jdom

    Hello
    I have been looking for a simple example that uses Jdom to read am xml file and use the information for anything( ), and I just can't find one.since I'm just beggining to understand how things work, I need a good example.thanks
    here is just a simple cod for example:
    <xmlMy>
         <table>
              <item name="first" value="123" createdDate="1/1/90"/>
              <item name="second" value="456" createdDate="1/4/96"/>
         </table>
         <server>
              <property name="port" value="12345"/>
              <property name="maxClients" value="3"/>
         </server>
    </xmlMy>Dave

    Hi,
            FileInputStream fileInputStream = null;
            try {
                fileInputStream = new FileInputStream("my_xml_file.xml");
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            } finally{
                if (fileInputStream == null) return;
            SAXBuilder saxBuilder = new SAXBuilder();
            saxBuilder.setEntityResolver(new EntityResolver() {
                public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
                    return new InputSource(new StringReader(""));
            Document document = null;
            try {
                document = saxBuilder.build(fileInputStream);
            } catch (JDOMException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            } finally {
                if (document == null) return;
            Element element = document.getRootElement();
            System.out.println(element.getName());
            System.out.println(element.getChild("table").getName());

  • Could u plz help me to find simple example for how to save data file in a spread sheet or any other way in the real time controller for Sbrio 9642 using memory or usb flash memory

    Could u plz help me to find simple example for how to save data file in a spread sheet or any other way in the real time controller for Sbrio 9642 using memory or usb flash memory

    Here are a few Links to a helpful Knowledge Base article and a White Paper that should help you out: http://digital.ni.com/public.nsf/allkb/BBCAD1AB08F1B6BB8625741F0082C2AF and http://www.ni.com/white-paper/10435/en/ . The methods for File IO in Real Time are the same for all of the Real Time Targets. The White Paper has best practices for the File IO and goes over how to do it. 
    Alex D
    Applications Engineer
    National Instruments

  • Need help with a simple basketball game.

    Hi im new here and I need help with making this simple basketball game.
    Im trying to recreate this game from this video. Im not sure if he is using as2 or as3
    Or if anyone could help me make a game like this or direct me to a link on how to do it It would be greatly appreciated.

    If you couldn't tell whether it is AS2 or AS3, it is doubtful you can turn it from AS2 into AS3, at least not until you learn both languages.  There is no tool made that does it for you.

  • Need help in simple function

    Hi,
    i am using sql developer to write a simple function .which need to get job details by using employ number
    ..below is the function
    CREATE OR REPLACE
    FUNCTION Q_JOB(empno1 in emp.empno%type) RETURN VARCHAR2 AS
    job1 varchar2(100);
    BEGIN
    select job into job1 from
    emp where empno=empno1;
    dbms_output.put_line('job :'||job1);
    RETURN job1;
    END Q_JOB;
    when i am trying to run this using command
    execute q_job(7369);
    i am getting folowing error..
    PL/SQL: Statement ignored
    06550. 00000 - "line %s, column %s:\n%s"
    *Cause:    Usually a PL/SQL compilation error.
    *Action:
    can any one tell whats exact problem is?

    You can use execute only for procedures, not functions.
    You have different possibilities:
    * If you like issuing the statement from a worksheet, use an anonymous block:
    DECLARE
      v_job  emp.job%type;
    BEGIN
      v_job = q_job(7369);
    END;
    / * Alternatively, use your function in SQL:
    SELECT q_job(7369) FROM DUAL; * For editing and testing your PL/SQL code, sqldev has very cool features: editor, compiler and debugger.
    Under the Functions node under your connection, you'll find your function: right-click and Edit it. Just above your code you have a mini-toolbar to Compile your code, Run or Debug it. A lot more on this inside the Help topics.
    Using the last 2 possibilities will provide you the returned value, so using dbms_output in your function isn't even necessary.
    Have fun,
    K.

Maybe you are looking for