VERY simple chat

I've been playing around with network programming, and I'm trying to create a simple chat system. I've already got the client side done, but I'm wondering how I should do the chat server.
I wanted the server to be something in the middle. Say I have two chat clients, I want the server to be running anonymously in the background relaying the messages back and forth. I'm just having problems figuring out how that I would get the server to register more than one client, and rely the message to the other clients.
Could you guys give me some comments/suggestions on this? Does my idea sound dumb?

Could you guys give me some comments/suggestions on
this? Does my idea sound dumb?Not at all. Check these out for examples:
http://www-106.ibm.com/developerworks/edu/j-dw-javachat-i.html
http://access1.sun.com/codesamples/J2SE-MultiCastSockets.html
http://www.cs.ucsb.edu/~cappello/290i/lectures/rmi/chatNew.html

Similar Messages

  • Simple Chat Client using Java

    Hi again. I'm thring to implement a simple chat client into my game and I need some help coding it, because it's way over my head. lol thanks

    Well, you have left your question very vague, and people tend to get irritated by it. First of all, you need to really specify what you need. If you have nothing and need everything....you need to start by thinking about what methods will be used to send the messages...the GUI should be the last part. Do you need a server, plan on using a public server, or in a LAN environment. If you need a server, what type? Do you plan on writing your own?
    For example, if you wanted to use an IRC server as your server, you could use PircBot as your backend for the communication and then integrate that into a GUI. If you wanted AOL, there are packages out there you can use.
    If you have things thought out, you need to tell us what you are really asking and what you aready have. Otherwise, you have a lot of things to think about.

  • Please help (Simple chat programme)

    I made a simple chat programme.
    It has a server object and it can handle several client.
    It is working properly and can use to chat.
    I have some problems. can you please help me.
    1.What is the best method to read input and outputStreams
    I have used inputStream.readUTF()/outputStream.writeUTF() methods and
    also I have used bufferedReader.readLine()/Printwriter.println() methods.
    I don't know about other methods.So please tell me what is the best and new out of these two.
    And are there any method which is better than these two.
    2.Is there any way to get more details from input and output streams
    Here more details means Fontcolor,Size etc;
    by now I'm adding them in to my output streams and filtering them when rea input stream.
    I'm getting other details(Fontcolor,Size) and add them all to a string.
    that means if client type "hi" my string will be something like this
    "12ff0000hi".
    When read the input stream i make a char[] and take first 2 chars to integer next six to a string and rest
    to another string.
    I think now you can understand my concept. So I'll not tell every thing.(if you want i can fully describe it)
    I' feeling this is very bad way to do that kind of work.
    Am i correct?
    so can you give me some hints or examples to do such kind of things.

    Here's a simple DataInputStream program that talks to itself. It runs the server as a seperate thread.
    import java.io.*;
    import java.net.*;
    public class DataXfer
            private int port = 5050;
            private String address="127.0.0.1";
            public static void main(String args[])
                    new DataXfer().startup();
            // run the server code as a thread and then run the client code
            private void startup()
                    new Thread(new Runnable(){public void run(){listen();}}).start(); // start server thread
                    synchronized(this){
                            try{wait();}catch(InterruptedException ie){}    // wait until its ready
                    connect();                                      // do client stuff     
            private void listen()
                    ServerSocket ss = null;
                    Socket us = null;
                    boolean running = true;
                    try{
                            System.out.println("Listening on port "+port);
                            synchronized(this){notify();}               // tell client we're ready
                            ss = new ServerSocket(port);    // listen for incoming connection
                            us = ss.accept();
                            ss.close();
                            ss = null;
                            DataInputStream dis = new DataInputStream(us.getInputStream());
                            try{
                                    while(running){
                                            int len = dis.readShort();      // read the count
                                            byte [] ba = new byte[len];
                                            int rlen = dis.read(ba,0,len);  // read the data
                                            System.out.println("len="+len+" read length="+rlen);
                                            if(rlen < len){
                                                    us.close();
                                                    running = false;
                                            else{
                                                    for(int j = 0; j<rlen; j++)System.out.print(ba[j]+" ");
                                                    System.out.println("");
                            catch(EOFException ee){System.out.println("EOF");}
                    catch(IOException ie){
                            ie.printStackTrace();
                            System.exit(0);
                    finally{
                            if(ss != null)try{ss.close();}catch(IOException se){}
                            if(us != null)try{us.close();}catch(IOException ue){}
            private void connect()
                    Socket us=null;
                    byte [] ba = new byte[31];
                    for(byte i = 0; i<ba.length; i++)ba=i;
    try{
    System.out.println("Connecting to "+address+":"+port);
    us = new Socket(address, port); // make connection
    System.out.println("Connected");
    DataOutputStream dos = new DataOutputStream(us.getOutputStream());
    for(int j = 0; j<ba.length;j+=10){
    dos.writeShort(j); // write the count
    dos.write(ba,0,j); // write the data
    System.out.println("sent "+j+" bytes");
    try{Thread.sleep(1000);}catch(InterruptedException ie){}
    catch(IOException ie){ie.printStackTrace();}
    finally{
    if(us != null)try{us.close();}catch(IOException ue){}
    For an example of a chat program using NIO see my NIO Server Example. That example is neither short nor simple.

  • My problem is very simple......firefox wont allow me save my downloads to any other location than my c drive....for example i have gone into options and set sav

    ''locking this thread as duplicate, please continue at [https://support.mozilla.org/en-US/questions/986549 /questions/986549]''
    my problem is very simple......firefox wont allow me save my downloads to any other location than my c drive....for example i have gone into options and set save downloads to my e drive....but still firefox keeps saving them to my c drive....i have 4 internal hard drives in my rig....and have tried saving downloads to them all.......why this is happening i cant understand....i have tried lots of suggestions....and have re-installed firefox multiple times

    hello, there's a general regression in firefox 27 that won't allow files to download directly into a root drive. please try to create a subfolder (like ''E:\Downloads'') and set this as default location for downloads...
    also see [https://bugzilla.mozilla.org/show_bug.cgi?id=958899 bug #958899].

  • Problem with very simple 2 threads java application

    Hi,
    As fa as i'm concerned this is a thread licecycle:
    1. thread created: it is dead.
    2. thread started: it is now alive.
    3. thread executes its run method: it is alive during this method.
    4. after thread finishes its run method: it is dead.
    No I have simple JUnit code:
    public void testThreads() throws Exception {
    WorkTest work = new WorkTest() {
    public void release() {
    // TODO Auto-generated method stub
    public void run() {
    for (int i=0;i<1000;i++){
    log.debug(i+":11111111111");
    //System.out.println(i+":11111111111");
    WorkTest work2 = new WorkTest() {
    public void release() {
    // TODO Auto-generated method stub
    public void run() {
    for (int i=0;i<1000;i++){
    log.debug(i+":22222222222");
    Thread workerThread = new Thread(work);
    Thread workerThread2 = new Thread(work2);
    workerThread.start();
    //workerThread.join();
    workerThread2.start();
    //workerThread2.join();
    And
    public interface WorkTest extends Runnable {
    public abstract void release();
    And that's it..
    On the console I see 999 iterations of both threads only if i uncomment
    //workerThread.join();
    //workerThread2.join();
    In other case I see random number of iterations - JUNIT finishes and Thread1 made 54 and Thread2 233 iterations - the numbers are different every time i start the JUnit..
    What I want? Not to wait until the first one finishes - I want them to start at the same time and they must FINISH their tasks...
    Please help me asap :(

    This is very simple... Look at your code:
    workerThread.start();
    workerThread.join();
    workerThread2.start();
    workerThread2.join();What are you doing here? You start the first thread, then you call join(), which waits until it finishes. Then after it's finished, you start the second thread and wait until it finishes. You should simply do this:
    workerThread.start();
    workerThread2.start();
    workerThread.join();
    workerThread2.join();I.e., you start the 2 threads and then you wait (first for the first one, then for the second one).

  • Problem With Deploying a very simple Servlet

    HELP REQUIRED:
    Hi,
    I'm including code of a very simple Servlet application (I shd not call it an application):
    index.html
    ==========
    <html><body bgcolor="#FFFFFF">
         <head>
         <title> Rajeev Asthana </title>
    <form action = "/HelloWorldApp/HelloWorld" method = "POST" >
    Please press Submit
    <input type = "submit" value = "Press Me!">
    </form>
    </body></html>
    HelloWorld.java
    ===============
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class HelloWorld extends HttpServlet {
         public void doPost(HttpServletRequest request,
                   HttpServletResponse response)
              throws ServletException, IOException {
              response.setContentType("text/html");
              PrintWriter out = response.getWriter();
              out.println("<html><body bgcolor=\"#FFFFFF\">");
              out.println("<p>Hello World!</p>");
              out.println("</body></html>");
              out.close();
    web.xml
    ========
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee" version="2.4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <display-name>HelloWorldApp</display-name>
    <servlet>
    <display-name>HelloWorld</display-name>
    <servlet-name>HelloWorld</servlet-name>
    <servlet-class>HelloWorld</servlet-class>
    </servlet>
    </web-app>
    sun-web.xml
    ===========
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 8.0 Servlet 2.4//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_2_4-0.dtd">
    <sun-web-app xmlns="http://java.sun.com/xml/ns/j2ee">
    <context-root>/HelloWorldApp</context-root>
    <session-config>
    <session-manager persistence-type="memory">
    <manager-properties/>
    <store-properties/>
    </session-manager>
    <session-properties/>
    <cookie-properties/>
    </session-config>
    <cache enabled="false" max-entries="4096" timeout-in-seconds="30">
    <default-helper/>
    </cache>
    <class-loader delegate="true"/>
    <jsp-config/>
    </sun-web-app>
    I have deployed it in following directory structure:
    C:\Sun\AppServer\domains\domain1\applications\j2ee-modules\HelloWorldApp\
    |
    |
    |               |               |               |
    |               |               |               |
    META-INF          WEB-INF          HelloWorld.java          index.html
                   |
                   |
              |          |          |          |
              |          |          |          |
         classes          sun-web.xml     web.xml          sun-j2ee-ri-project
         |
         |
         HelloWorld.class
    While generating HelloWorldApp.war (which is the war file for this app), I specifies /HelloWorldApp as context root (sun specific).
    Now, when I deployed it thru Admin Tool and then clicked on "Launch", it displays a page with :
    Please press Submit Press Me!
    But when I click the button "Press Me!", it says:
    "The requested resource (/HelloWorldApp/HelloWorld) is not available."
    What should I do to correct the problem?
    Thanks in advance.
         

    Yes, you need to add a servlet -mapping element and adjust your form to submit to the appropriate URL mapping.
    <servlet-mapping>
    <servlet-name>HelloWorldServlet</servlet-name>
    <url-pattern>/servlet/Hello</url-pattern>
    </servlet-mapping>

  • I am going to buy a macbook pro for grade 12, and I need to know wheather I should get a macbook pro or a macbook pro retina. If someone could tell me (in a very simple way) which one is,better for me and why, I would be ever so apprreciative.

    I am going to buy a macbook pro for grade 12, and I need to know wheather I should get a macbook pro or a macbook pro retina. If someone could tell me (in a very simple way) which one is,better for me and why, I would be ever so apprreciative.

    Why do you need a expensive MacBook Pro?
    Your attending high school and unless everyone else is rich also your likely going to be a target by the more poorer students for theft or damage to the machine.
    You could keep it home, but if you need it for class then your exposed again.
    Also at that age your not very careful yet, a MacBook Pro is a expensive and easily damaged machine.
    Unless your made of money and so are others at your school, I would recommned a low profile, just does the job cheap Windows PC.
    If it dies, gets lost, stolen or damaged because of your inexperince handling senstivie electronics then it's no big deal.
    You can buy a Mac later on when your sure you have a need for it, currently there isn't much advantage of owning a Mac compared to a PC, they do just about the same things now, one just looks prettier than the other.
    Since 95% of the world uses Windows PC's your going to have to install Windows on the Mac in order to keep your skills up there or be unemployed, so it's a extra headache and expense.
    good luck

  • Very simple EJB 3.0 MDB but I get NullPointerException

    I tried to create a very simple EJB 3.0 Message Driven Bean in JDeveloper 10.1.3.2 as follows:
    Message Driven Bean Class:
    import javax.ejb.MessageDriven;
    import javax.jms.Message;
    import javax.jms.MessageListener;
    @MessageDriven(mappedName="MDBQueue")
    public class MDB implements MessageListener {
    public void onMessage(Message message) {
    System.out.println("Got message!");
    Application Client:
    import javax.annotation.Resource;
    import javax.jms.*;
    public class MDBAppClient {
    @Resource(mappedName="MDBQueueConnectionFactory")
    private static QueueConnectionFactory queueCF;
    @Resource(mappedName="MDBQueue")
    private static Queue mdbQueue;
    public static void main(String args[]) {
    try {
    QueueConnection queueCon = queueCF.createQueueConnection();
    QueueSession queueSession = queueCon.createQueueSession
    (false, Session.AUTO_ACKNOWLEDGE);
    QueueSender queueSender = queueSession.createSender(null);
    TextMessage msg = queueSession.createTextMessage("hello");
    queueSender.send(mdbQueue, msg);
    System.out.println("Sent message to MDB");
    queueCon.close();
    } catch(Exception e) {
    e.printStackTrace();
    But I get the following error:
    java.lang.NullPointerException
         at model.MDBAppClient.main(MDBAppClient.java:17)
    I read similar problem in the this thread:
    Re: message driven bean on ejb 3.0 does not work
    some one said that the version in ejb-jar.xml must be changed from 2.1 to 3.0
    but in this case there is no ejb-jar.xml.
    ( I have other cases with ejb-jar.xml file but I can't change the version in ejb-jar.xml)
    the version in web.xml is 2.4 but it not accept any value except 2.4 and an error occur when I tried to change it to 3.0
    please can you tell me why I get NullPointerException and how can I allow EJB 3.0 MDB and JMS to work in JDeveloper

    Note that you can't run MDBs in the embedded OC4J in JDeveloper - try deploying to a stand-alone install of OC4J and see if it works there.

  • I want to  download Mavericks on my iMac.  I presently have 10.6.8. Sadly I am a total klux when downloading and need very simple advice please.

    I want to upgrade from O S 10.6.8 but am a total klux when downloading.  Instructions have to be very simple.  Thanks a lot.

    Check to make sure your applications are compatible. PowerPC applications are no longer supported after 10.6.      
    Application Compatibility
    Applications Compatibility (2)

  • Very Simple Problem-- Need help in method selection process

    Hello,
    It's difficult to explain the background of the program I am making-- but I am stuck at a very simple problem, that I can only solve with a very long block of if statements:
    I have 3 possible numbers-- 1, 2, or 3.
    Imagine two numbers are already taken-- say 1 and 2. I want a variable to set itself to the number that's not taken (3).
    So, again: If two numbers were taken say 2 or 3-- I want the variable to be sent to the other one that isn't taken-- 1.
    Thank you for your help,
    Evan.

    Actually, I'll just tell you the context of the program-- here is what I have so far:
    This program is meant to simulate Monty Hall Problem:
    http://en.wikipedia.org/wiki/Monty_Hall_problem
    The program sets up an array of three possible values. Each one of those values represents a door with either a goat or a car behind it. It then randomly sets one of those values to 1 (in order to represent a car as per the Monty Hall problem), and 0's represent goats.
    The user, which is simulated by the program (does not involve actual interaction), chooses a door initially.
    The game show hosts then reveals a door that is not the users initial choice, but IS a goat ( an array value of 0).
    For example if the array was [0][0][1]
    The user could pick door one (array position 0). Which is a goat.
    The game show host then reveals a goat that is not the users choice-- which would be array position 1.
    After the game show host reveals the goat-- I want the user to always switch his decision to the only other remaining door that was not his first choice.
    Then I wanted the computer to test to see if his final choice is the one with a car. And to tally up the amount of times he got it right.
    --Sorry that was long winded:
    import TerminalIO.*;//imports TerminalIO package for system.out.println
    import java.util.*;//import java.util for random
    public class Monty_Problem
         int doors[]= {0,0,0};
         Random rand= new Random();
         double wins,totals=0;
         public void carAssignment()
              int car_door= rand.nextInt(3);
              doors[car_door]=1;
         public int judgesChoice(int judgeDoor, int initialChoice)
              if(judgeDoor != initialChoice && doors[judgeDoor]!=1)
                   return judgeDoor;
              else
                   return judgesChoice(rand.nextInt(3), initialChoice); //infinite loop right here that I cannot remedy.  I want the program to have the judge pick a location that is not occupied by a  '1' and is not the user's choice. 
         public void gamePlaySwitches()
              int initialChoice= rand.nextInt(3);
              int judgeDoor = 0;
              int secondChoice= 0;
              judgeDoor= judgesChoice(rand.nextInt(3), initialChoice);
              //This part is meant to have the user switch choices from his initial choice
                   // to the only other choice that hasn't been revealed by the judge. 
              while(secondChoice == initialChoice || secondChoice== judgeDoor)
                   secondChoice++;
              if(doors[secondChoice]==1)
                   wins++;
                   totals++;
              else
                   totals++;          
         public static void main(String [] args)//creates the main menu
              Monty_Problem a= new Monty_Problem();
              int games=0;
              while(games!=100)
                        a.carAssignment();
                        a.gamePlaySwitches();
                        games++;
              System.out.println(a.wins/a.totals);
    }Edited by: EvanD on Jan 11, 2008 4:17 PM

  • How to create  a very simple dyamic tree with rich faces

    hi i have spent more than 5 days trying to make a very simple rich faces tree but with no result
    i want to make a very simple dyamic tree
    for example i have a button when i click it.i want to add two nodes in my tree("node 1" and "node 2")
    i have also failed in making even a static tree with richfaces i think that some thing is wrong with them i checked the live demo website
    http://livedemo.exadel.com/richfaces-demo/richfaces/tree.jsf?c=tree
    i have tried the source code but with no result :(
    thank you

    You can try something like this
    <rich:tree switchType="server" >
    <rich:treeNodesAdaptor nodes="#{CB.calendarioHandler.organizacion.departamentos}"
    var="departamento">
    <rich:treeNode>
    <h:outputText value="#{departamento.nombre}"/>
    </rich:treeNode>
    <rich:treeNodesAdaptor nodes="#{departamento.empleados}"
    var="empleado">
    <rich:treeNode>
    <h:outputText value="#{empleado.nombre}"/>
    </rich:treeNode>
    <rich:treeNodesAdaptor nodes="#{empleado.calendarios}"
    var="calendario">
    <rich:treeNode>
    <h:outputText value="#{calendario.nombre}"/>
    </rich:treeNode>
    </rich:treeNodesAdaptor>
    </rich:treeNodesAdaptor>
    </rich:treeNodesAdaptor>
    </rich:tree>
    where departamentos, empleados and calendarios are just simple pojos lists.
    I hope to help.
    Edited by: sfdgd on Apr 1, 2009 6:40 PM

  • Creating a very simple XML-driven gallery

    Hi, I'm learning XML in AS3 and I am having real trouble finding a resource that can help me learn how to build a very simple XML-driven picture gallery.
    I am working in an FLA file with AS3, with a dynamic text field with the instance name "textfield". I also have a UILoader Component with the instance name "UILoaderComponent" and an XML file called "rootdir.xml".
    I have an XML file in the following format.
    <images>
         <imagenames>
              <name>image1</name>
              <name>image2</name>
              <name>image3</name>
              <name>image4</name>
              <name>image5</name>
         </imagenames>
         <imagepaths>
              <path>image1.jpg</path>
              <path>image2.jpg</path>
              <path>image3.jpg</path>
              <path>image4.jpg</path>
              <path>image5.jpg</path>
         </imagepaths>
    </images>
    I am using the following as my actionscript.
    var xmlLoader:URLLoader = new URLLoader();
    var xmlData:XML = new XML();
    xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
    xmlLoader.load(new URLRequest("rootdir.xml"));
    function LoadXML(e:Event):void {
    xmlData = new XML(e.target.data);
    parseImg(xmlData);
    function parseImg(imgLoad:XML):void {
    var imgChild:XMLList = imgLoad.images.children();
    for each (var imgTrace:XML in imgChild) {
    trace(imgTrace);
    No matter which way I experiment, I always have poor results with my dynamic text, and every tutorial I've followed does not reproduce anything like the same returned data in "textfield" that it does with the trace command.
    My objective is: I simply want to build a menu inside a textbox called "textfield" that lists images1-5, and when clicked, calls upon the relevant image. For instance: I load the file "rootdir.xml" into the file "index.fla". I call a function to parse the XML into a dynamic text box called "textfield". When image 2 is clicked on the textbox "textfield", it would call upon a function that would load into the UIComponent Loader "image2.jpg".
    Are there any tutorials for this? I'm so confused as to why dynamic text operates so differently from the trace command. I'm not interested in doing a fancy menu bar with thumbnails, scrollbars and animations, I just want to learn the basics.

    I don't really see how you are getting a valid trace out of that code (I get nothing if I try it as is), but as far as the textfield goes, you haven't shown any attempt in your code that might help to point to why you cannot get the text into a textfield.  It might be a problem with how you are trying to write to the textfield and not how your are manipulating the data.
    While you could make use of a textfield for the menu, doing so is not straightforward, as you would need to implement htmlText with special coding in order to have the text clickable.  You might consider using a List component or ComboBox instead.
    What I always do when I am working with xml is to store the data into a data structure, usually an array conatining objects, and then make use of that structure rather than dippng into the xml data itself when I utilize the data.
    Another thing, which rquigley demonstrated, is that your xml will serve its purpose better if the data for each image is collected under the same node.  If you have separate sections for each piece of data like you have, when it comes to editing it will be more prone to error as you have to be sure you are editing the correct entry of each separate group.
    I too am no expert in the world of xml, but I have not yet worked with parameters inside the tags, so I would usually structure it as...
    <images>
       <image>
           <imgName>image 1</imgName>
           <imgPath>image1.jpg</imgPath>
       </image>
       <image>
           <imgName>image 2</imgName>
           <imgPath>image2.jpg</imgPath>
       </image>
    </images>
    Now, back to what you have...  let's say you have a textField named imgText that you want to list the image names in.  The following should work, though I do not go my usual route of storing the data into an object array first...
    function parseImg(imgLoad:XML):void {
       var imgNames:XMLList = imgLoad.imagenames.name;
       var imgPaths:XMLList = imgLoad.imagepaths.path;
       // show name
       for each (var nameTrace:XML in imgNames) {
          trace(nameTrace);
          imgText.appendText(nameTrace +"\n");
       // show path
       for each (var pathTrace:XML in imgPaths) {
          trace(pathTrace);
          imgText.appendText(pathTrace +"\n");
       // show name and path
       for(var i:uint=0; i<imgNames.length(); i++){
          trace(imgNames[i].text()+"  "+imgPaths[i].text());
          imgText.appendText(imgNames[i].text()+"  "+imgPaths[i].text() +"\n");

  • Very simple mp3 player

    What is an easy way to create a very simple flash mp3 player
    in DW CS3? I
    tried the DW mp3 plugin, but that caused confusion for
    visitors who did not
    know how or want to install a plugin. I googled "flash mp3
    player" and
    there are many available, but they support play lists and
    many other
    features. I just want to play one static mp3 url and have
    Quicktime-like
    controls of play, pause, rewind, etc. Any suggestions or
    tutorials on how
    to do this? If there is a simple tutorial on how to roll your
    own in Flash,
    I have Master Collection which includes Flash.
    Best,
    Christopher

    I spent a couple of days reviewing various flash mp3 players
    on the net and
    decided to use SoundPlayer from FlashLoaded.com. For $35 it
    works OK. But
    here's my question. Why doesn't DW CS3 include a flash mp3
    player component
    similar to the flv player? Or did I miss it? Yes, I know the
    generic
    plugin can be used, but that requires visitors to install an
    additional
    plugin. Adding mp3 players to web pages would seem like a
    common problem in
    search of a simple solution in DW; why isn't a flash solution
    included with
    DW CS3 and/or Flash CS3? Am I missing something? This was my
    first Flash
    project, so perhaps I overlooked the obvious.
    Best,
    Christopher

  • 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.

  • Very simple, but not working Table to Flat File

    I'm new to ODI, but I am having too much difficulty in performing a very basic task. I have data in a table and I want to load the data to a flat file. I've been all over this board, all over the documentation, and all over the Googles, and I can not get this to work. Here is a run down of what I have done thus far:
    1. created a physical schema under FILE_GENERIC that points to my target directory
    2. created a logical schema that points to my new physical schema
    3. imported a test file as a model (very simple, two string columns, 50 chars each)
    4. set my parameters for my file (named columns, delimited, filename resource name, etc.)
    5. created a new interface
    6. dragged my new file model as the target
    7. dragged my source table as well
    8. mapped a couple of columns
    9. had to select two KMs: LKM - SQL to SQL (for the source) & IKM - SQL to File Append (for the target)
    10. execute
    Now, here is where I started hitting problems. This failed in the "load data" step with the following error:
    +7000 : null : java.sql.SQLException: Column not found: C1_ERRCODE+
    I found a note on the forum saying to change the "Staging Area Different From Target" setting on the Definition tab. Did that and selected the source table's schema in the dropdown, ran again. Second error:
    +942 : 42000 : java.sql.SQLException: ORA-00942: table or view does not exist+
    This occurred in the "Integration - insert new rows" step.
    The crazy thing is that in a step prior to this ("Export - load data"), the step succeeded and the data shows up in the output file!
    So why is ODI trying to export the data again? And why am I getting an ORA error when the target is a file?
    Any assistance is appreciated...
    A frustrated noob!
    Edited by: Lonnie Morgan (CALIBRE) on Aug 12, 2009 2:58 PM

    I found the answer. But still not sure why this matters...
    Following this tutorial, I recreated my mapping:
    [http://www.oracle.com/technology/obe/fusion_middleware/ODI/ODIproject_table-to-flatfile/ODIproject_table-to-flatfile.htm]
    I was still getting the same error. I reimported my IKM and found that the "Multi-Connections" box was unchecked before and now it was checked. I may have unchecked it in my trial & error.
    Anyway, after running the mapping again with the box checked, the extract to a file worked.
    So, I'm happy now. But, I am also perturbed with the function of the this checkbox and why it caused so much confusion within ODI.

Maybe you are looking for