Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-01-2008, 06:02 PM
Member
 
Join Date: Sep 2008
Posts: 42
Rep Power: 0
matpj is on a distinguished road
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!

Thank you very much in advance..

Matt
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 12-01-2008, 06:17 PM
CJSLMAN's Avatar
Moderator
 
Join Date: Oct 2008
Location: Mexico
Posts: 1,149
Rep Power: 2
CJSLMAN is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 12-01-2008, 08:04 PM
xcallmejudasx's Avatar
Senior Member
 
Join Date: Oct 2008
Location: Houston, TX & Flint, MI
Posts: 472
Rep Power: 1
xcallmejudasx is on a distinguished road
Send a message via AIM to xcallmejudasx
Default
BufferedWriter, FileWriter, you will need those
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 12-02-2008, 12:10 PM
Member
 
Join Date: Sep 2008
Posts: 42
Rep Power: 0
matpj is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 12-02-2008, 12:22 PM
serjant's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Ukraine,Zaporozhye
Posts: 451
Rep Power: 2
serjant is on a distinguished road
Send a message via ICQ to serjant Send a message via Skype™ to serjant
Default
it will take one hour.Maybe even less then one hour.
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 12-02-2008, 12:25 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 6,525
Rep Power: 9
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
I think it takes less than one hour.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Someone helped you?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.
Help:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Resources:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Web:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Tips:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 12-02-2008, 12:28 PM
Member
 
Join Date: Sep 2008
Posts: 42
Rep Power: 0
matpj is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
  #8 (permalink)  
Old 12-02-2008, 12:29 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 6,525
Rep Power: 9
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
It's take time lol. With experience you can do it.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Someone helped you?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.
Help:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Resources:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Web:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Tips:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #9 (permalink)  
Old 12-02-2008, 12:31 PM
serjant's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Ukraine,Zaporozhye
Posts: 451
Rep Power: 2
serjant is on a distinguished road
Send a message via ICQ to serjant Send a message via Skype™ to serjant
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.
Bookmark Post in Technorati
Reply With Quote
  #10 (permalink)  
Old 12-02-2008, 12:34 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 6,525
Rep Power: 9
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
In that period of time you can do a lot. Best thing is should tryout yourself. It's make a huge difference lol.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Someone helped you?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.
Help:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Resources:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Web:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Tips:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #11 (permalink)  
Old 12-02-2008, 01:19 PM
Nicholas Jordan's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Southwest
Posts: 1,018
Rep Power: 3
Nicholas Jordan is on a distinguished road
Default mustard
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
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.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
.
Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor
Bookmark Post in Technorati
Reply With Quote
  #12 (permalink)  
Old 12-02-2008, 02:01 PM
Member
 
Join Date: Sep 2008
Posts: 42
Rep Power: 0
matpj is on a distinguished road
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!
Bookmark Post in Technorati
Reply With Quote
  #13 (permalink)  
Old 12-02-2008, 05:29 PM
xcallmejudasx's Avatar
Senior Member
 
Join Date: Oct 2008
Location: Houston, TX & Flint, MI
Posts: 472
Rep Power: 1
xcallmejudasx is on a distinguished road
Send a message via AIM to xcallmejudasx
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.
Bookmark Post in Technorati
Reply With Quote
  #14 (permalink)  
Old 01-06-2009, 06:23 PM
Member
 
Join Date: Sep 2008
Posts: 42
Rep Power: 0
matpj is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
  #15 (permalink)  
Old 01-06-2009, 11:26 PM
serjant's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Ukraine,Zaporozhye
Posts: 451
Rep Power: 2
serjant is on a distinguished road
Send a message via ICQ to serjant Send a message via Skype™ to serjant
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
Bookmark Post in Technorati
Reply With Quote
  #16 (permalink)  
Old 01-07-2009, 04:42 AM
Nicholas Jordan's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Southwest
Posts: 1,018
Rep Power: 3
Nicholas Jordan is on a distinguished road
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.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
.
Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
isolated task in java sardare Threads and Synchronization 4 09-07-2008 08:54 PM
Ant exec task JavaForums Java Blogs 0 05-20-2008 12:40 PM
java : how to hide application icon from a task bar yogeshagashe Advanced Java 0 03-12-2008 01:05 PM
Task Blocks 0.5 johnt Java Announcements 0 08-08-2007 08:43 PM
Where to proceed now? Ixnay New To Java 4 07-29-2007 07:16 PM


All times are GMT +2. The time now is 03:29 AM.



VBulletin, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org