Hello,
Sending herewith the code
--------java code------
import java.applet.*;
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import sun.jdbc.odbc.JdbcOdbcDriver;
public class Survey extends Applet {
Label blankLine = new Label(" ");
TextField name = new TextField(50);
TextField pwd = new TextField(50);
Button submitButton = new Button("Submit");
public void init() {
setLayout(new GridLayout(21,1)); Panel panels[]=new Panel[21];
for(int i=0;i<panels.length;++i){ panels[i]=new Panel();
panels[i].setLayout(new FlowLayout(FlowLayout.LEFT)); }
submitButton.addActionListener(new ButtonHandler());
panels[0].add(blankLine);
panels[1].add(new Label("Name:"));
panels[2].add(blankLine);
panels[3].add(name); panels[4].add(blankLine);
panels[5].add(new Label("Password:"));
panels[6].add(pwd);
panels[7].add(blankLine); panels[8].add(submitButton);
panels[20].add(blankLine);
for(int i=0;i<panels.length;++i) add(panels[i]); }
void updateDatabase()
{
try{ // Load
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:mjs1";
url+="conn?dbtype=odbc&dsn=mjs1'"; // Connect to database
Connection connection=DriverManager.getConnection(url);
Statement statement = connection.createStatement();
String sql="INSERT INTO pwd VALUES (`"+pwd.getText()+"'";
sql+=",'"+name.getText()+"'"; sql+=")";
// Execute SQL
statement.executeUpdate(sql);
// Close database connection
connection.close();
displayPanel("Thank you!");
}
catch(Exception ex){
displayPanel(ex.toString());
}
} String toDigit(Checkbox ch){
boolean state = ch.getState(); if(state) return ",'1'"; else return
",'0'";
} void displayPanel(String s){ removeAll(); setLayout(new BorderLayout());
Font currentFont = getFont();
setFont(new Font(currentFont.getName(),Font.ITALIC+Font.BOLD,18));
add("Center",new Label(s,Label.CENTER)); invalidate(); doLayout(); }
class ButtonHandler implements ActionListener {
public void actionPerformed(ActionEvent e){
String s = e.getActionCommand();
if("Submit".equals(s))
{ updateDatabase(); }
}
}
}
Thanks in advance,
With Regards,
MJS
servlet-SOL <[EMAIL PROTECTED]> wrote:
Man it works cool for me.
Can u post ur code.
Srini
----- Original Message -----
From: MJS MJS <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, December 25, 1999 11:02 AM
Subject: A query which doed not stictly belong to this forum
> Hello everyone,
> Is there any way to design an applet for JDBC access without using A 3RD
party
> driver?The JDBCODBC bridge does not seem to work.My back end is Access 97
> Any help would be greatly appreciated
> Thanks in advance,
> MJS
>
>
> ____________________________________________________________________
> Get free email and a permanent address at http://www.netaddress.com/?N=1
>
>
___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
____________________________________________________________________
Get free email and a permanent address at http://www.netaddress.com/?N=1
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html