Results 1 to 16 of 16
  1. #1
    matpj is offline Member
    Join Date
    Sep 2008
    Posts
    42
    Rep Power
    0

    Default New to Java - not sure how to proceed with my new task

    Hi guys/girls,

    having been on a Java course (only a week) in the beginning of september and not using it since, I seem to have forgotten a lot of what I learnt.


    The problem is that I need to start using it this week or early next in order to write an application to read from a database and output a text file of the results.
    This sounds very straight forward, but I havent got a clue where to start!

    Can anyone on here provide guidance.
    Even with some sample code dealing with a simple SQL Select stament and outputting a simple text file of the output (thats essentially what I will b doing)


    I have no problem with the SQL side of it.
    Just the Java side! :D

    Thank you very much in advance..

    Matt

  2. #2
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    7

    Default some links...

    Here's some links to help you along the way...

    Luck,
    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

  3. #3
    xcallmejudasx's Avatar
    xcallmejudasx is offline Senior Member
    Join Date
    Oct 2008
    Location
    Houston, TX & Flint, MI
    Posts
    609
    Rep Power
    6

    Default

    BufferedWriter, FileWriter, you will need those

  4. #4
    matpj is offline Member
    Join Date
    Sep 2008
    Posts
    42
    Rep Power
    0

    Default

    thanks for the links.

    Out of interest.
    If you were aksed to write something seemingly as straight forward as that, would you find it a straight forward task.
    How long would it take an expert to develop a simple app with an interface allowing a command button to run the program and maybe a browse box to select a location for the text file?

    Thanks again,
    Matt

  5. #5
    serjant's Avatar
    serjant is offline Senior Member
    Join Date
    Jun 2008
    Location
    Ukraine,Zaporozhye
    Posts
    487
    Rep Power
    7

    Default

    it will take one hour.Maybe even less then one hour.

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  7. #7
    matpj is offline Member
    Join Date
    Sep 2008
    Posts
    42
    Rep Power
    0

    Default

    damn. I wish I knew what I was doing!
    i'll have a look at those links.
    at the moment I can just about muster up a application that writes hello world to the console! lol

  8. #8
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  9. #9
    serjant's Avatar
    serjant is offline Senior Member
    Join Date
    Jun 2008
    Location
    Ukraine,Zaporozhye
    Posts
    487
    Rep Power
    7

    Default

    For being good in Java,you should sit every day and read the java tutorials,and code some programs,then you will succeed,I ensure you if you do that every day at least three hours day,in three monthes you can write a swing application.Don't be lazy.

  10. #10
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    In that period of time you can do a lot. Best thing is should tryout yourself. It's make a huge difference lol.

  11. #11
    Nicholas Jordan's Avatar
    Nicholas Jordan is offline Senior Member
    Join Date
    Jun 2008
    Location
    Southwest
    Posts
    1,018
    Rep Power
    8

    Default mustard

    Quote Originally Posted by matpj View Post
    damn. I wish I knew what I was doing!
    i'll have a look at those links.
    at the moment I can just about muster up a application that writes hello world to the console! lol
    Java Code:
    import java.io.FileWriter;// 
    class muster{
      private FileWriter fw;
      public static void main(String[] args){
          try{
          fw = new FileWriter("muster.mustard");
          fw.write( SQL stuff );//
          fw.flush and close() ....
          }catch(java.io.IOException ioe){}
    }
    Grossly abbreviated and needing major code blocks, but as the others direct, practicing every day is the only way. Here, I practice on your dime while making coffee and waking up - I find that this allows me to step into large projects with an effective skill base.

    In short, get a String from the SQL - you state that is already known - then just write it to a file using FileWriter, which has to be in a try / catch block. Further, if a class has a flush method, use it before closing the file as main can exit before the file is written to disk. Try also Buffered Writer and be sure to use the ( String , start position , length ) form of the call as I have found that writes taking just a string or just a byte[] seem to skip past the actual work and do nothing.
    Introduction to Programming Using Java.
    Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor

  12. #12
    matpj is offline Member
    Join Date
    Sep 2008
    Posts
    42
    Rep Power
    0

    Default

    Thanks guys, I appreciate your help. I wasn't expecting anybody to write the code for me, more directing me as to the best place to start, i.e. what classes would I possibly need to write, what sequence of events and things to look out for :-)

    Thanks again, i'll start the long task of learning it - although I don;t have much in the way of free time to do it.
    wish me luck!

  13. #13
    xcallmejudasx's Avatar
    xcallmejudasx is offline Senior Member
    Join Date
    Oct 2008
    Location
    Houston, TX & Flint, MI
    Posts
    609
    Rep Power
    6

    Default

    The more you program the simpler things get. Even harder tasks become "easy" in the sense you just have to look up the commands to work with them. Getting a firm grasp on things like inheritance, class interaction, polymorphism, and being able to visual what is happening internally when you run a program are what make you a good programmer.

  14. #14
    matpj is offline Member
    Join Date
    Sep 2008
    Posts
    42
    Rep Power
    0

    Default

    Sorry to drag this up again, but I am a little further along!
    I have been reading Java for dummies to refrsh my memory with certain things.
    I have no created a VERY simple java program which connects to a database, reads and displays the results in the results pane within my IDE.

    I guess what I am after is for someone to suggest how I should structure my program.
    I will utlimately be performing the read and writing the results to a text file.
    I just don't know how to construct it.
    What classes should I create?
    do I need one for reading and one for writing?
    Do I need to create any at all?
    or do I put it all in the Main method of my actual program class?

    i'll be creating a GUI at some stage for users to press 'go' and maybe select a value from a drop down, which will affect the SQL in the read...

    Thanks in advance,
    Matt

  15. #15
    serjant's Avatar
    serjant is offline Senior Member
    Join Date
    Jun 2008
    Location
    Ukraine,Zaporozhye
    Posts
    487
    Rep Power
    7

    Default

    Iа you really want to create a real secure program with SQL and to know what technology is used nowadays in some firms in JDBC i recommend you to read tutorial about iBatis.Or if it is complicated for you,there are much tutorials about sql with jdbc,search on google

  16. #16
    Nicholas Jordan's Avatar
    Nicholas Jordan is offline Senior Member
    Join Date
    Jun 2008
    Location
    Southwest
    Posts
    1,018
    Rep Power
    8

    Default

    It is as serjant and xcallmejudasx direct, do a program that stores "Hello World" and can recover that from a file using the skills and approaches described in post titiled "#14 Today, 11:23 AM" - for text files, use some class in java.io that has the name Writer ( or Reader ) in the class name.

    It won't work at first, ( probably ) but that is where you would start based on the books that you are reading.
    Introduction to Programming Using Java.
    Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor

Similar Threads

  1. isolated task in java
    By sardare in forum Threads and Synchronization
    Replies: 4
    Last Post: 09-07-2008, 08:54 PM
  2. java : how to hide application icon from a task bar
    By yogeshagashe in forum Advanced Java
    Replies: 0
    Last Post: 03-12-2008, 01:05 PM
  3. Task Blocks 0.5
    By johnt in forum Java Software
    Replies: 0
    Last Post: 08-08-2007, 08:43 PM
  4. Where to proceed now?
    By Ixnay in forum New To Java
    Replies: 4
    Last Post: 07-29-2007, 07:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •