This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes Database ...need to implement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Database ...need to implement" Watch "Database ...need to implement" New topic

Database ...need to implement

Kajol Shroff
Ranch Hand

Joined: Dec 04, 2000
Posts: 160
HI Everybody,
I am working on a project which is basically a client side application (applet using cardlayout). See i have few textfields in which the user can put in his data and at the end of the last step he has the option to SAVE, PRINT & ORDER.
When he says SAVE then it should print on the client side in file format (txt)... and the same goes for PRINT too..
When he says ORDER it should ask the user to go online if he notis online.. and when he is online it should store the data in the database (MySQL).
Hey let me tell u i doono anything about how to go about it.........i mean how to go ahead about it..
Can anybody please help me out in this...
Can i know is there a similar example..............where in i can get the case-study and get the clear picture..
Help me out please guys...
[This message has been edited by Kajol Shroff (edited April 18, 2001).]
Kajol Shroff
Ranch Hand

Joined: Dec 04, 2000
Posts: 160
Hi Everybody,
Why there is no reply from all you guys??
I need to implement the database connectivity ....
PLease help me out
Bob Reardon
Ranch Hand

Joined: Jun 01, 2000
Posts: 160
Have you tried getting information from this resource:
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
There was a reply to your query that disappeared when the site crashed this week. Sorry about that, but here is the gist of what was posted:
You could store the user's form input in an array until they click the save button. Then when they click it, you would have to step through the array and build the contents into some kind of delimited string ( you could use ; or : or even | ). Then you would have to make the server-side of your application parse the string to make use of it. Is this what you had in mind?
Kajol Shroff
Ranch Hand

Joined: Dec 04, 2000
Posts: 160
Hi Bodie,
Thanks for ur reply..........Can u give me some example... as it would be easier for me to understand it ...
Thanks a million..
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
A code example would be more than I can do for you this morning, but let me try to give you a short description of what I am talking about.
Let's say you have a form with the following fields on it: Name, Address, Phone number. Your form also has two buttons: Save changes, and Add New Entry. The user can click Add New Entry and put in a new Name, Address, and Phone Number as many times as they like. You can create a new class called Contact, for example. Each time they click Add New Entry, their previous entries are stored in a new contact object, which in turn is stored in a vector. When they finally finish making entries they click the Save Changes button. Now their final entry is stored as a Contact object in the vector. Now you can step through the vector and generate a SQL Statement to insert the rows into the database all at once.
Sorry if my earlier post was confusing. I forgot that you said you were using an Applet to do this. I was responding as though you were using JSP or a Servelet to handle the processing and database interaction.
[This message has been edited by Bodie Minster (edited April 20, 2001).]
Monty Ireland
Ranch Hand

Joined: Oct 03, 2000
Posts: 161
The following code examples is NOT a total solution to your problem. But, will shoud you how to implement an applet using the Layout manager(s) interacting with a database via jdbc 1.0.
This example does NOT ues threads... It should to be more efficient...
FYI... do no forget to use the politytool utility to grant permissions...
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import java.util.*;
public class JdbcTest9 extends Applet {
Label lb1 = new Label( "Userid" );
TextField tf1 = new TextField(15);
Label lb2 = new Label( "Password" );
TextField tf2 = new TextField(15);
Button bt1 = new Button("Execute Sql");
Button bt2 = new Button("Reset Sql");
Button bt3 = new Button("Reset Result Set");
Button bt4 = new Button("Reset All");
Label lb3 = new Label( "Sql Code" );
TextArea ta1 =
new TextArea( "select * from aTable", 05, 40, SCROLLBARS_BOTH );
Label lb4 = new Label( "Result Set" );
TextArea ta2 = new TextArea( "", 05, 40, TextArea.SCROLLBARS_BOTH );
public void init() {
Panel p0 = new Panel();
p0.setLayout( new BorderLayout() );
Panel p1 = new Panel();
p1.setLayout( new GridLayout( 2, 4) ) ;
p1.add( lb1 );
p1.add( tf1 );
p1.add( lb2 );
p1.add( tf2 ); tf2.setEchoChar('*');
bt1.addActionListener( new ActionListener() {
public void actionPerformed(ActionEvent e) {
boolean editTF;
editTF = false;
editTF = editTFInput();
if ( editTF ) {
} else {
showStatus("Invalid input - Try Again ...");
}// end of if
}// end of actionPerformed method
} );// end of anaonymous class 'ActionListener'
p1.add( bt1 );
bt2.addActionListener( new ActionListener() {
public void actionPerformed(ActionEvent e) {
showStatus("Reset Sql ...");
}// end of actionPerformed method
} );// end of anaonymous class 'ActionListener'
p1.add( bt2 );
bt3.addActionListener( new ActionListener() {
public void actionPerformed(ActionEvent e) {
showStatus("Reset Result Set ...");
}// end of actionPerformed method
} );// end of anaonymous class 'ActionListener'
p1.add( bt3 );
bt4.addActionListener( new ActionListener() {
public void actionPerformed(ActionEvent e) {
showStatus("Reset All ...");
}// end of actionPerformed method
} );// end of anaonymous class 'ActionListener'
p1.add( bt4 );
p0.add( p1, BorderLayout.NORTH );
Panel p2 = new Panel();
p2.setLayout( new GridLayout( 4, 4 ) ) ;
p2.add( lb3 );
p2.add( ta1 );
p2.add( lb4 );
p2.add( ta2 );
p0.add ( p2, BorderLayout.CENTER );
this.add( p0 );
} // end of init
public boolean editTFInput() {
boolean editTF;
editTF = true;
if ( tf1.getText().length() != 7 ) { editTF = false; }
if ( tf2.getText().length() < 6 | | tf2.getText().length() > 8 ) {
editTF = false; }
return editTF;
}// end if method editTFInput

public void executeSql() {
try {
String userid, password;
Vector queryResults = new Vector();
showStatus("Loading JDBC Driver ..." );
showStatus("Connecting To jdbc:db2SNT ..." );
userid = tf1.getText().trim().toUpperCase();
password = tf2.getText().trim().toUpperCase();
Connection con =
DriverManager.getConnection("jdbc:db2SNT", userid, password );
showStatus("Creating SQL Statement ..." );
String sqlsel1 = ta1.getText();
showStatus("Creating Java Statement Class ..." );
Statement stmt = con.createStatement();
showStatus("Executing SQL VIA JAVA Statement ..." );
ResultSet rs = stmt.executeQuery( sqlsel1 );
showStatus("Processing Result Set VIA JAVA Statement ..." );
// result set meta data
ResultSetMetaData meta = rs.getMetaData();
// add java result set to a vector
while ( ) {
StringBuffer strbuf = new StringBuffer();
for ( int icol = 1 ; icol <= meta.getColumnCount() ; icol++ ) {
strbuf.append( " " );
strbuf.append( rs.getString( icol ) );
strbuf.append( "\n" );
String rows = strbuf.toString();
strbuf.setLength( 0 );
queryResults.addElement( rows );
} // end of while
// add vector to a text area component
Enumeration enum = queryResults.elements();
while (enum.hasMoreElements()) {
String rows = (String)enum.nextElement();
ta2.append( rows );
} // end of while
queryResults.removeAllElements();// empty vector
rs.close();// close ResultSet
stmt.close();// close Statement
con.close();// close Connection
}// end try block

catch(ClassNotFoundException e) {
showStatus("ClassNotFoundException!!!: " );
ta2.append("ClassNotFoundException!!!: " + e ) ;
catch(SQLWarning e) {
showStatus("SQL_CODE !!!: " );
ta2.append("SQL_CODE !!!: " + e ) ;
catch(SQLException e) {
showStatus("SQL_CLASS !!: " );
ta2.append("SQL_CLASS !!: " + e ) ;
}// end of catch block(s)
} // end of executeSql
}// end of class JdbcTest9
Multi-Platform Database Developer ( on E.S.T. )

Multi Platform Database Developer & DBA on E.S.T.
I agree. Here's the link:
subject: Database ...need to implement
Similar Threads
Connection to JDBC
hibernate saving multiple hierarchy records
Frame for my window
Remote Access
Servlets connection