Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-22-2008, 05:46 PM
Member
 
Join Date: Jan 2008
Posts: 2
staticy2003 is on a distinguished road
Java program that stores user inputs
Hello
I am almost new in Java, and i have to do a program in java that acquires the user inputs from a file or from the interaction with the GUI, and stores these data in a database.
I installed MYSQL, since it is opensource...
Anyone has any suggestion?
Thanks in advance
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 01-22-2008, 08:39 PM
CaptainMorgan's Avatar
Moderator
 
Join Date: Dec 2007
Location: NewEngland, US
Posts: 841
CaptainMorgan will become famous soon enoughCaptainMorgan will become famous soon enough
Send a message via AIM to CaptainMorgan
Welcome to the Java Forums!

Have you attempted writing the code yet? If so, please post it if you get stuck - and please use code tags. You can start by reviewing both the Database forums for some posts related to yours, and/or have a view at this site's Tutorials where there are a few threads regarding databases.

MySQL is a good choice.. however, you say you're "almost new", and I'm not sure what you mean by that. For beginner Java programmers, this assignment you have to do requires the use of some more advanced concepts. But post your code and ask your specific questions, we're here to help.

See you around!
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
to our beloved Java Forums!
(closes on September 4, 2008)
Want to voice your opinion on your IDE/Editor of choice?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
!
Got a little Capt'n in you? (drink responsibly)
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 01-23-2008, 07:52 AM
Member
 
Join Date: Jan 2008
Posts: 16
sandeeprao.techno is on a distinguished road
Before writing the program you have to create a DSN and then create tables in that particular DSN and then carry on with the code, also set the classpath for the database.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 01-23-2008, 08:11 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 3,574
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
First create required tables and stuff in the database first.

Then think that how to connect database to a Java application. At that point you can learn a lot about database connections. There few number of connections are available for Java.

Then try to find out that how to write data to a database table. Just use some values which is on your application itself included. Don't think about GUI and user command line inputs, etc.

At last try to work with user inputs.

Likewise try to step out your question first. Then try to do something. Then put your code here and all the members help you to solve your question. Don't worry about that you are a newbie for Java. This project is a very good one to start work with Java. Try and see.

Good luck pal...
__________________
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.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
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.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 01-23-2008, 10:08 AM
Member
 
Join Date: Jan 2008
Posts: 2
staticy2003 is on a distinguished road
Thank you very much for your answers. It helped me a lot. Now I am going to try the different ways for doing this program and in anycase, if something doesn't work I'll put the code here.
Thanks a lot
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 01-23-2008, 10:19 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 3,574
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Yep pal, that's better first start some work. We all are ready to help you at any time.
__________________
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.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
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.
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 01-24-2008, 08:46 PM
Member
 
Join Date: Jan 2008
Posts: 20
JAdmin is on a distinguished road
Here is a sample code to connect to a MySQL database

Code:
Database name : yourdatabase Databse user : aUser Database password : aPwd import java.sql.*; Connection conn = null; Statement stmt = null; ResultSet rs = null; try{ Class.forName(com.mysql.jdbc.Driver); conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/yourdatabase",aUser,aPwd); //Create a Statement object. stmt = conn.createStatement(); //Get a ResultSet rs = stmt.executeQuery("select * from users"); //Loop through the results while(rs.next()){ String userName = rs.getString("user"); System.out.println(userName ); } }catch( Throwable t){ //handle error here t.printStackTrace(); } finally{ //note the sequence of closing the objects. rs first // followed by stmt and connection try{ if(rs != null) rs.close(); }catch(Throwable t){t.printStackTrace();} try{ if(stmt != null) stmt.close(); }catch(Throwable t){t.printStackTrace();} try{ if(con != null) con.close(); }catch(Throwable t){t.printStackTrace();} }
Always remember to close your objects in a finally block. That is the time tested best practice.

Hope this helps!

Sincerely, your friends at JavaAdvice.com

Last edited by JAdmin : 01-25-2008 at 01:06 AM.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


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

vB 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
How to execute an External Program through Java program Java Tip java.io 0 04-04-2008 03:40 PM
Java Security Applet will not load under a specific user. MartyF Java Applets 0 03-31-2008 05:35 PM
How do I update a WINDOWS user env variable from my java code ? gavman99 Advanced Java 0 02-06-2008 03:07 PM
Date Inputs hiranya AWT / Swing 3 11-06-2007 06:11 PM
How to execute an External Program through Java program JavaBean Java Tips 0 10-04-2007 10:33 PM


All times are GMT +3. The time now is 02:13 AM.


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