Meaningless Drivel is fun!*
The moose likes JDBC and the fly likes java database applet with Internet Explorer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Reply locked New topic
Author

java database applet with Internet Explorer

vishesh jain
Greenhorn

Joined: Jul 22, 2005
Posts: 3
Hi

I have a problem with my java applet, I connect my java applet with the database
& accessing & comparing the database using some condition statement applet is working fine
with appletviewer, I write an policy file in the same directory, I use the
following command:

appletviewer -J-Djava.security.policy=DbaOdbPol.txt login.html

but when I am running my Applet in Explorer it is not showing any result.

I am sendig you the code what exactle I did.
I am also sendig you this as an attachment.

Please send me the solution as soon as possible.


Java source code: login.java:-

import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.sql.*;
public class login extends Applet implements ActionListener {
Graphics g;
private String text,sourceurl;
Image background;
TextField user=new TextField(20);
TextField pass=new TextField(20);
Button welcome=new Button("Welcome");
Font font;
Color mycolor;
int red,green,blue;
private Connection con;
public void init() {
pass.setEchoChar('*');
background=getImage(getCodeBase(),"leaf.gif");
setLayout(null);
welcome.setBackground(Color.lightGray);
user.setBounds(120,27,140,20);
pass.setBounds(120,67,140,20);
welcome.setBounds(90,110,130,20);
font=new Font("Times New Roman",Font.BOLD,15);
red=Integer.parseInt(this.getParameter("red"));
green=Integer.parseInt(this.getParameter("green"));
blue=Integer.parseInt(this.getParameter("blue"));
mycolor=new Color(red,green,blue);
add(user);
add(pass);
add(welcome);
welcome.addActionListener(this);
user.addActionListener(this);
pass.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
String command=e.getActionCommand();
if (command.equals("Welcome"))
{
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
sourceurl=new String("jdbc dbc:MS Access 97 Database");
con=DriverManager.getConnection(sourceurl);
compareValues();
}
catch (SQLException ex)
{
System.out.println("Connection Error = " + ex.toString());
}
catch(ClassNotFoundException ex1)
{
System.out.println("Error loading ");
}
}
}
public void compareValues()
{
String userstr,passstr,s;
userstr=user.getText();
passstr=pass.getText();
try {
Statement stmt = con.createStatement();
int counter = 1;
ResultSet rset = stmt.executeQuery("SELECT * FROM userpswd");
while (rset.next())
{
if(userstr.equals(rset.getString(1)) && passstr.equals(rset.getString(2)))
{
try{
AppletContext ac=getAppletContext();
URL url=getCodeBase();
ac.showDocument(new URL(url+"welcome.html"));
showStatus("Fatching Values");
}
catch(MalformedURLException er)
{
showStatus("url not found");
}
}
else
{
counter++;
}
}
}
catch (SQLException ex)
{
System.out.println("Error While Fetching Values = " + ex.toString());
}
}

public void paint(Graphics g) {
g.drawImage(background,0,0,null);
g.setFont(font);
g.setColor(mycolor);
g.drawString("Username",45,40);
g.drawString("Password",45,80);

}
}


Html code: login.html:-

<html>

<head>
<title>BHELEDN,Bangalore LogIn</title>
</head>

<body bgcolor="FFFF3:00 P3:01 PM 7/5/20053:01 PM 7/5/200"
background="Pictures/j0396147.jpg">

<p align="center"><br>
<font color="#00FF80"><br>
</font><font face="Times New Roman" size="5" color="#004F75">BHELEDN,Bangalore</font><font
face="Times New Roman" size="4" color="YELLOW"> </font><img
SRC="Pictures/htmlpicturesblue.jpg" ALIGN="TOP" BORDER="2" WIDTH="740" HEIGHT="5"
NATURALSIZEFLAG="0"> <br>
</p>

<p align="center"> </p>

<p align="center"><br>
<br>
<br>
<applet code="login.class" ARCHIVE="dbtool.jar" width="300" height="150"
style="border: medium solid rgb(0,102,151)">
<param name="red" value="0">
<param name="green" value="81">
<param name="blue" value="119">
</applet>
<br>
<br>
<br>
<br>
</p>
</body>
</html>


Policy file: DbaOdbPol.txt:-

grant {
permission java.security.AllPermission;
};
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30076
    
149

Closing accidental duplicate post. See other thread


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
Don't get me started about those stupid light bulbs.
 
subject: java database applet with Internet Explorer
 
Similar Threads
call applet problem
ColorText
Dynamic JSP
java database applet with Internet Explorer
java database applet with Internet Explorer