DATABASE APPLET
HELLO TO ALL
MY APPLET IS USING ODBC AND CONNECTING TO ACCES.
I HAVE CREATED POLICY FILE SO THAT I CAN DISPLAY APPLET IN APPLETVIEWER.
APPLET RUNS FINE IS APPLETVIEWER WITH FOLLOWING COMMANDLINE
Appletviewer -jDJava.security.policy = pol label.htm.
however when i try to display applet in web browser, it display
following error message "load-Can't instantiate class"
any help will be welcome
@MITZ:
Christ, stop hijacking and multi-posting this same question all over the place!!!
http://forum.java.sun.com/thread.jspa?threadID=707757
http://forum.java.sun.com/thread.jspa?threadID=5186205
http://forum.java.sun.com/thread.jspa?threadID=5190321
http://forum.java.sun.com/thread.jspa?threadID=5187789
http://forum.java.sun.com/thread.jspa?threadID=5190317
@people who want to answer MITZ:
I suggest doing so in the thread which was posted in the Signed Applets section of this forum:
http://forum.java.sun.com/thread.jspa?threadID=5190324
Similar Messages
-
Hi!
I just got Jdeveloper 2.0 Beta, and trying to go through the
tutorial. I have completed the Database Applet Tutorial
successfully and it works fine within Jdeveloper.
Then I did the Deployment part in order to run this applet in a
Web environment. But the thing is that our Database and the web
server reside in two different machines.
I know the database must be on the same server as the web server
in order to run this applet. And it also says that if the
database is not in the same server as the web server use
Connection Manager.
Where can I find more information about connection manager. Or
how can I run this applet using a remote database. (Both servers
are on the same network)
TIA
Sri.
nullI tried putting my web server, etc. on the same machine as my database but this didn't solve the problem. I'm still getting No suitable Driver.
Any help is much appreciated, thanks,Spencer
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by mark tomlinson ([email protected]):
You need to check the following.
1. In your CMAN.ora file veryfy that the port the
cman is listening on is same port specified in your
connect string.
2. The CMAN is installed on the same machine as the
webserver.
The following is an example of a cman.ora file, the
cman is listening on port 1610
cman = (ADDRESS_LIST =
(ADDRESS = (PROTOCOL=TCP)
(HOST=)
(PORT=1610)))
cman_profile = (parameter_list =
(MAXIMUM_RELAYS=512)
(LOG_LEVEL=1)
(TRACING=YES)
(RELAY_STATISTICS=YES) (SHOW_TNS_INFO=YES)
(USE_ASYNC_CALL=YES) (AUTHENTICATION_LEVEL=0) )
Then your connect string should look like
Connection conn =
DriverManager.getConnection ("jdbc:oracle:thin:" +
"@(description=(address_list=" +
"(address=(protocol=tcp)(host=webHost)(port=1610))"
+
"(address=(protocol=tcp)(host=oraHost)(port=1521)))
" +
"(source_route=yes)" +
"(connect_data=(sid=orcl)))", "scott", "tiger");
The first element in the address_list entry
represents the connection to the Connection
Manager. The second element represents the database
to which you want to connect. The order in which
you list the addresses is important.<HR></BLOCKQUOTE>
null -
How to deploy database Applets
I use JDeveloper to build applets. What is the best way to
deploy database applets to the 9iAS Portal?
marcelMy application is targeted toward home users with an Internet connection but minimal computer knowledge. It is not clear to me how I could install and configure a database server using WebStart, and doing it manually would hopelessly overwhelm my target audience. So I opted for a simple embedded PureJava database which stores information in ASCII files.
I have several such files containing product data catalogs which I need to transfer using WebStart and write to a standard, platform-independent directory (i.e. no C:\ or such) which my JDBC URL can then access. I can pack my data files into a JAR and programmatically extract them on the client side. However, the problem is finding out what the application's client-side default path is in order to save my files to a standard location. It appears that the default path is the Windows Desktop the first time the app is started, but changes to the application's home directory (C:\Program Files\Java Web Start\.javaws\cache\...\myApp) thereafter.
Any hints or suggestions? -
Database applet not working in browser
I am working on windows 2000 server. I have an applet that connects to a ms access database.Everything works in appletviewer. When i try to view the applet in ie i get the following error:
Error: java.security.AccessControlException: access denied (java.lang.RuntimePermission accessClassInPackage.sun.jdbc.odbc)
null
Error: java.security.AccessControlException: access denied (java.lang.RuntimePermission accessClassInPackage.sun.jdbc.odbc)
null
access denied (java.lang.RuntimePermission accessClassInPackage.sun.jdbc.odbc)
Basically i am trying to serve the applet on IIS. When I try to access the html page from
a different machine, the applet loads and looks good except fails to connect with the database and display
data.
Any help will be highly appreciated.
fnjoelYou are not allowed to access Databases directly form an applet
This is a security issue in Java Applets. -
Database applet error in web browser
hi to all
i have query in applet.
MY APPLET IS USING ODBC AND CONNECTING TO ACCES.
I HAVE CREATED POLICY FILE SO THAT I CAN DISPLAY APPLET IN APPLETVIEWER.
APPLET RUNS FINE IS APPLETVIEWER WITH FOLLOWING COMMANDLINE
Appletviewer -jDJava.security.policy = pol label.htm.
however when i try to display applet in web browser, it display
following error message "load-Can't instantiate class"
any help will be welcome@MITZ:
Christ, stop hijacking and multi-posting this same question all over the place!!!
http://forum.java.sun.com/thread.jspa?threadID=707757
http://forum.java.sun.com/thread.jspa?threadID=5186205
http://forum.java.sun.com/thread.jspa?threadID=5190321
http://forum.java.sun.com/thread.jspa?threadID=5187789
http://forum.java.sun.com/thread.jspa?threadID=5190317
@people who want to answer MITZ:
I suggest doing so in the thread which was posted in the Signed Applets section of this forum:
http://forum.java.sun.com/thread.jspa?threadID=5190324 -
I have to create a Java applet, but I don't know how. It should display a simulation of running rabbit in 10 circles, explaining the For cycle in a programming language C. I tried to make it in NetBeans, but I couldn't. Can anubody please help me? Any hint, useful site or line of code... I would be very grateful.
mneskovic wrote:
I'm sorry. I'm just in deadline,.. For the record. Not our fault, not our problem, and mentioning deadlines does not encourage people to help.
..so I lose my nerves easy... In that case, I strongly suggest you re-read all your posts before sending them off. If they have a hint of 'lost nerves' they are likely to irritate the very people who might otherwise help you. I think you can guess that is not conducive to getting a good, timely, technical solution.
..OK, let's deal with the problem.
I was looking for the solution of posted problem on the Internet and found that I should sign in my applet. Since I work in NetBeans, I enabled Web start because it looked like the fastest way to do it. .. That statement reads like nonsense to me. Perhaps NetBeans has some automagic script that presumes a JWS application needs to be digitally signed and does that for each build. If that is the case, I just found another reason to dislike it.
..My applet has database connection (connection to MySQL database - applet has text field and input from it is recorded in database) which works just fine in Applet Viewer. .. Are you launching the AppletViewer using NetBeans?
..When I enabled Web Start, I finally could see applet in Web page, but now I don't have database connection, there is no recording in database when I make input from text field...Are you looking for exceptions in the Java Console?
The post you made earlier shows no sign of adding the Jar containing the DB driver to the archive attribute of the applet element. That is the most logical reason why the applet would not be able to connect to the DB.
Note that I am still pretty unimpressed by your efforts to get help with this. I linked to an earlier thread where I asked you questions and you then abandoned the thread. You can partly restore my motivation to help by copy/pasting those questions to this thread and answering the questions.
These problems will not be sorted by some 'magic line of code'. You need to understand what is happening. I see no sign you are gaining that understanding. -
Problem while I try to run Applet using Appletviewer
Hi,
I have developed a simple Applet using JDeveloper 1.1, here I am
using a Dataset, a QueryDataSet and a grid.
When I run the Applet within JDeveloper it runs just fine, but
when I use the Appletviewer, the Applet starts of well but gives
the following error:
"borland.jbcl.dataset.DataSetException: Operation cannot be
performed on an open DataSet"
Please let me know what I am doing wrong.
Thanks,
Prag.
nullThis may be a problem with JDK inconsistency problem. Make sure
your appletviewer IS Java 1.1 compliant. Also, have you properly
deployed your applet to a jar file?
Here are the instructions for deploying a database applet:
Hope this helps..
-Chris
Task 7: Deployment
The following requirements apply when deploying a database
applet:
The database must be on the same server as the Web Server (or use
a connection manager).
Must have a JDK 1.1 compatible browser, such as Netscape 4.0.4 or
Internet Explorer 4.0.
Creating the Java Archive (.jar) file
Select File|New
Click the Deployment tab
Double-click the Simple Archive Profile icon.
The Simple Archive Profile wizard (SAP wizard) is displayed.
On the Welcome page, click Next.
On page one of the SAP wizard, enter or browse to set the Archive
Path. Set the name of the jar to db_applet.jar.
Click Next.
Page two displays the names of all files in your project. Accept
the default value of deploying all of the files and click Next.
On page three, Dependencies, shift-click each item in the list
"List items that you do not want to appear in the archive to
select them all.
Click Remove.
In most cases, developers prefer to ship only their own classes
in the .jar file, with separate .jars that store common files
used by all of their Java programs. For the sake of simplicity,
you are going to create a .jar file that includes all of the
classes necessary to run your applet. By removing all of the
libraries, you indicate that no classes should be omitted from
your deployed .jar file.
Click Finish.
Deploying the applet
Using a file manager, copy the db_applet.jar file you have just
created to the Web Server.
Copy the tutorial.EmpApplet.html file to the same directory as
your .jar file.
The tutorial.EmpApplet.html file can be found in the project
directory (by default, the \myprojects directory under the
JDeveloper root directory) or you can extract the file from the
.jar using any PK-ZIP compatible file compression utility.
Using any text editor, modify the <APPLET> tag in the
tutorial.EmpApplet.html file to include an ARCHIVE tag that
references your .jar file. Your <APPLET> tag should include this
information:
<APPLET CODEBASE = "." CODE = "tutorial.EmpApplet.class"
NAME = "TestApplet" WIDTH = 400 HEIGHT = 300 HSPACE
= 0 VSPACE = 0 ALIGN = middle ARCHIVE =
"db_applet.jar">
To test the applet, open the tutorial.EmpApplet.html file through
a web server using a Java 1.1 enabled browser.
Congratulations! You have completed your first database applet.
You created a program that queries data from Oracle tables,
displays the data in data-aware controls, allows for viewing and
editing, displays status messages to a StatusBar, and includes a
NavigatorControl component.
Prag Ratra (guest) wrote:
: Hi,
: I have developed a simple Applet using JDeveloper 1.1, here I
am
: using a Dataset, a QueryDataSet and a grid.
: When I run the Applet within JDeveloper it runs just fine, but
: when I use the Appletviewer, the Applet starts of well but
gives
: the following error:
: "borland.jbcl.dataset.DataSetException: Operation cannot be
: performed on an open DataSet"
: Please let me know what I am doing wrong.
: Thanks,
: Prag.
null -
Hi All
I m extracting data from SQL table onto xMII Dashboard using Grid template.I have one column named comments.
I need that the supervisor using the Dashboard can change the comments as required and it should be reflected on the dashboard as well as It is updated in the database.
Can anyone tell me how can I achieve this ? I am concerned whether I would be able to change an xMII Grid row ....
Regards
AmitHi Amit,
Add a cell selection event in your iGrid template definition
e.g.
<APPLET NAME="appDashBoard" WIDTH="100%" HEIGHT="250" CODE="iGrid" CODEBASE="/Illuminator/Classes" ARCHIVE="illum8.zip" MAYSCRIPT>
<PARAM NAME="QueryTemplate" VALUE="/your/query/template">
<PARAM NAME="DisplayTemplate" VALUE="/your/display/template">
<PARAM NAME="InitialUpdate" VALUE="true">
<PARAM NAME="CellSelectionEvent" VALUE="JavaScriptFunctionName">
</APPLET>
Create a query template to update new comment in database
<APPLET NAME="appUpdateComment" WIDTH="1" HEIGHT="1" CODE="iCommand" CODEBASE="/Illuminator/Classes" ARCHIVE="illum8.zip" MAYSCRIPT>
<PARAM NAME="QueryTemplate" VALUE="/update/comment">
</APPLET>
In your Java script function check whether the selected cell is part of the comment's column
if (appDashBoard,getSelectedCellColumn() == 'Comment'){
//capture new user comment
var comment = prompt('Enter comment', '');
//get record id from igrid for the selected comment
var cellRow = appDashBoard.getSelectedCellRow();
var rID = getCellValue(cellRow, columNumberOfID);
var appUpdateCommentQry= appUpdateComment.getQueryObject();
appUpdateCommentQry.setParam(1, rID);
appUpdateCommentQry.setParam(2, comment );
if(appUpdateComment.executeCommand()) {
} else {
appDashBoard.updateGrid(true); -
Best Practices for many Remote Objects?
Large Object Model doing JDBC over RMI
Please read the following and provide suggestions for a recommended approach or literature that covers this area well?
N-Tiered Architecture
JSP/Servlet (MVC) - Database Access Layer - Database
Applets - JSp/Servlet Engine - Database Access Layer - Database
Application Layer - Application Layer - Database Access Layer - Database
I have an object model developed using Torque (A JDBC Object Relational modeling framework) for over 100 tables (to be over 160) that I am commencing to enable over RMI. I have got several remote methods up and running. For some of the simple methods starting up has been easy. Going forward I forsee issues.
Each table has a wrapper or data object and a peer object that have setters/getters and special methods as desired. The majority of these classes are extended from Base Objects that have basic common functionality for retrieving, creating, and manipulating with a database using SQL.
I have started building a Remote Interface and an Implementation class that invoke the necessary methods and classes within the Object Model to pull successfully off or update the database. Additionally the methods will need to return objects that represent non-primitive serializable dataobjects and collections of objects.
Going forward client applications, servlets, and jsps will be using the database in more complex and comprehensive methods over rmi. Here are a couple of things I am concerned about.
1) When to use java.rmi.server.codebase for class loading? In my implementation several of the remote methods will return objects (e.g Party, Country, CountryList, AccountList). These objects themselves are composed of other objects that are not part of the jvm. For all remote methods that return non-primitive objects must you include the classes in the codebase for the client to operate upon them. Couldn't this be pointless as you have abstract and extended classes all residing within the codebase? In practice do people generally build very thin proxy objects for the peer/data objects to hold just the basic table elements and sets?
2) Server Versioning/Identity - Going forward more server classes will be enabled via rmi. Everytime one wants to include more methods on interface that is available must you update the interface, create new implementation classes, and redistribute the Remote Interface, and stubs/skels to client apps to operate on again? Is there some sort of list lookup that a client can do to say which processes are available remotely presently (not just at initialization)? As time changes more or fewer methods might be available?
Any help is greatly appreciated.More on Why other approaches would be better?
I have implemented some proxy objects for the remote Data Objects produced by Torque. To ease the pain, I have also constructed a proxy Builder that takes the table schema and builds a Proxy Object, an inteface for the proxy, and methods to copy between the Torque Data Object (which only lives on the server) into the Proxy Object (accessible by client and/or server).
The generated methods are useable in the object implementing the Remote Interface but are themselves not remoteable. Only the Server would use these methods. Clients can only receive primitives, proxy Objects, or collections of ProxyObjects.
This seems to be fairly light currently. I had to jump hoops to use Torque and enable remote apps to use the proxy objects. What would be the scaling issues that will come up? Why would EJBs with containers and all kinds of things about such as CMP vs BMP to be concerned with be a better approach?
Methods can be updated to do several operations verses Torque and return appropriately (transactions). In this implementation the client (Servlet, mini App or App) needs the remote stub and the proxy objects (100 or so) to stand in for the Torque generated Data Objects. A much smaller and lighter set of classes, based on common JDK classes, instead of the torque classes (and necessary abstracts/objects/interfaces/exceptions for Torque). -
(JC) static variable and derived object
Hi there!
It is glad to know you from Java Card Forum. Can I ask for your help on the following question?
It is about static variable. The following is my sample code:
========================================
package com.Test01;
import javacard.framework.*;
import javacard.security.*;
import javacardx.crypto.Cipher;
public class Test01 extends Applet {
OwnerPIN Pin;
static DESKey[] keys;
protected Test01(byte[] buffer, short offset, byte length) {
keys = new DESKey[4];
length = 0;
while (length < 4) {
keys[length] = (DESKey)KeyBuilder.buildKey((byte)3, (short)0x80, false);
length = (byte)(length + 1);
public static void install(byte buffer[], short offset, byte length) {
new Test01(buffer, offset, length);
===========================================================
If there are two instances, A and B, created in the package.
My issues:
1. Are keys[0]~ keys [3] kept while B is deleted?
2. Does each instance have itsown object while "keys[length] = (DESKey)KeyBuilder.buildKey((byte)3, (short)0x80, false);"? or they share the same object?
3. follow item 2, if A and B share the same object, is the object kept while B is deleted? Where can I get the information in Sun's spec?
Thank you very much.
Best regards,
kantieThanks a lot. You mean that keys variable will be removed while instance B deleted, right? I think the idea of database applet is very good, but I can't force applet provider the way of their implementations : )
I still got question, does it get no use to set the keys variable to be "static"? So that I can keep it to other instances, if applied.
And I think that any object derived under the static variable shall be kept, until the package is deleted.
For example, if you declare a static pointer, and it points to an object newed by the instance at the first time. We say every instances (A and B) of this package (PckM) share this same static pointer and this same object, right? There are two situations:
1. if this referred object is removed when B is deleted, so the memory of this object will be released. Then user might create an instace C of another package (PckN), and instance C new its objects just overlapping on the released memory. In this case, it will cause instance A to be crashed, because its static pointer has been referred to illeagle address.
2. if this referred object is kept when B is deleted, then instance C will new its objects in other free memory. In this case, instance A will work well, because its static pointer still refers to correct object.
What do you think? Am I missing any concepts?
Thank you for your great opinions.
Best regards,
kantie -
JDBC-ODBC bridge connection failure.
I'm new to JDBC and JDeveloper and am having some difficulty
getting through the database applet tutorial.
I'm trying to connect to a Microsoft Access database using the
JDBC-ODBC Bridge. This is an interim stage before using a Linux
Oracle database which is not yet up and running.
When trying to add a data form, the database wizard fails at
step 4 of 7 after selecting the Sun JDBC-ODBC bridge and the
required data source the following error is presented:
Connection error
Vendor code 84
[Microsoft][ODBC Microsoft Access 97 Driver]Driver not capable
I also tried setting up (using ODBC manager) a System DSN for a
text and Excel data source, but met similar problems e.g:
[Microsoft][ODBC Excel Driver]Driver not capable
Currently JDeveloper Beta 2.0 (build 184) and the ODBC source
are on the same NT4.0 (SP4) machine.
To confuse matters I'm actually running Access 95, rather than
Access 97.
I have previously successfully connected to an Access ODBC
source via JDBC in a Java application (not applet) when
following a tutorial example that comes with the Sun JDK 1.2. I
note, however, that jdbcodbc.dll that's part of JDK 1.2 is newer
(and bigger - 32K 01Dec98) than that supplied with the
JDeveloper Beta 2.0 (22K 05Nov98)
I'm a bit lost with this problem since nothing happens after
pressing help on the error dialog, and I'm not sure where to
look for log files etc. to further debug the problem. Any help
would be gratefully received!
nullThe error indicates that the bridge is making a call to the
driver which it cannot handle -- either because the call is
invalid/unreasonable or because the driver doesn't implement the
functionality requested. An ODBC trace will determine which of
the two is true. If the first, you need to contact the bridge
provider to get a fix. If the second -- the ODBC driver
provider.
null -
AppletViewer Socket security policies in Netbeans -
I'm developing a database applet using NetBeans IDE 4.0, jre 1.5.0. To make this easier, I set up a database server on my desktop with a dummy database to work with. I'm having a great deal of trouble getting the applet to connect to the database from AppletViewer. It throws the following error:
java.security.AccessControlException: access denied (java.net.SocketPermission 127.0.0.1:3306 connect,resolve)
I believe this is an applet security issue - the default of the JVM being not to allow connections to network resources located anywhere other than where the applet came from (or that are signed). The applet works ok if I move it over to the production web/db server, which confirms this suspicion. This is precisely the problem I was hoping to circumvent by setting up a db server on the localhost.
I've tried changing the code to point the connection to "localhost", the fqdn, and the actual IP of the machine. This just gives me the expected respective versions of the same error message. I've also tried adding items to the java.policy, to no avail.
I'm really hoping to be able to work on this thing without having to copy it over to the server and/or sign the applet every time I compile and test it. Any suggestions?No - the setup with the database on the local machine is just meant as a convenience while I'm developing it. When it's deployed all clients will hit the same DB, which is hosted on the same server that the web server serving the applet is on. This, actually, already worked. The trouble was with getting the local db to work while I'm developing.
I actually figured out a workaround. NetBeans' built in webserver has to be configured in the runtime options to load its own policy file. I added the socket permissions to that file and reloaded the server. Now when I compile/run the applet fromt the IDE it works.
Still doesn't work directly from the stand-alone AppletViewer, but this will do. -
Load:Tutorial.EmpApplet can't be instantiated ERROR
Hi,
By following JDevelopment 2.0 tutorial - Database Applet Tutorial
It was compiled successfully.
But when It was run, the ERROR occured !
" load:tutorial.EmpApplet can't be instantiated "
Anybody know why it happened ??
Thanks.
Youngho
nullUnfortunately these is a step missing in the tutorial for the
beta version. This is actually logged as a doc bug. Here is the
description:
For the database applet tutorial, you need to explicitly include
the JDBC classes111.zip file in the deployment archive. It does
not get pulled in automatically by the dependency checker.
Instructions for deployment need to instruct users to:
1. Click the Add File button for the Additions list box.
2. In the File Open dialog, navigate to and select the
aurora\lib\classes111.zip file.
3. Deploy.
Sorry, Roel.
Youngho Cho (guest) wrote:
: Hi,
: By following JDevelopment 2.0 tutorial - Database Applet
Tutorial
: It was compiled successfully.
: But when It was run, the ERROR occured !
: " load:tutorial.EmpApplet can't be instantiated "
: Anybody know why it happened ??
: Thanks.
: Youngho
null -
Hi,
I'm making a chat program and when users log on it should add their name to a mySQL database (it does that fine) when the user logs off it should delete their name from the database but it doesn't do that, it just adds another name, anyone know why? Here's my code:
code for server/adding names to dbase
import java.net.*;
import java.io.*;
import java.sql.*;
public class ChatServer implements Runnable
static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
static final String DATABASE_URL = "jdbc:mysql://localhost/users?user=mike&password=blitz84";
private Connection conn;
private Statement stat;
int index=-1;
SharedMsg sharedMsg;
Socket socket;
DataInputStream input;
PrintStream output;
String alias="";
boolean running=false;
boolean alive()
return running;
public ChatServer(Socket s,SharedMsg sm,int idx)
index=idx;
sharedMsg=sm;
socket=s;
try
input=new DataInputStream(socket.getInputStream());
output=new PrintStream(socket.getOutputStream(),true);
// output=new DataOutputStream(socket.getOutputStream(),true);
catch(IOException e)
System.out.println("Abnormal chat server socket condition 1:"+e);;
public void run()
try
doLoop();
input.close();
output.close();
socket.close();
catch(IOException e)
System.out.println("Abnormal chat server socket condition 2:"+e);;
public void doLoop() throws IOException
String line=null;
String data=null;
char command='W';
char ind=(char)index; //index of sender of msg
char broad=(char)-1; //goes to everybody
running=true;
while(true)
//loop: reads in msg, write it onto sharedmsg
line=input.readLine();
command=line.charAt(0);
data=line.substring(1);
if(command=='X')
sharedMsg.put(broad+"User: "+data+" Logged Out");
break;
else if(command=='S')
//first msg
alias=data;
sharedMsg.put(broad+"New User Logged: "+alias);
else
sharedMsg.put(ind+"From "+alias+": "+data);
String name = alias;
try
Class.forName(JDBC_DRIVER); //adding names here<<
conn = DriverManager.getConnection(DATABASE_URL);
stat = conn.createStatement();
String query = "insert into connected values('"+name+"')";
stat.executeUpdate(query);
stat.close();
catch(Exception e)
System.out.println("Error at "+e);
e.printStackTrace();
//exiting
running=false;
//new message arrived, send it over the socket
public void newMsg(String msg)
char mitt=msg.charAt(0);
String data=msg.substring(1);
//if(!msg.equals("") && msg!=null)
if(mitt!=(char)index)
//send
output.println(data);
output.flush();
synchronized(System.out)
System.out.print(".\b");
System.out.flush();
This is the code that should delete it when they exit
import java.awt.*;
import java.net.*;
import java.io.*;
import java.sql.*;
public class ChatApplet extends Frame implements Runnable
static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
static final String DATABASE_URL = "jdbc:mysql://localhost/users?user=mike&password=blitz84";
private Connection conn;
private Statement stat;
static String command; //shared resource
Socket socket;
static final int portNumber=1666;
//Thread commReader=null;
DataInputStream input;
PrintStream output;
String alias=null;
boolean logging=true;
TextArea textArea;
TextField comm;
Label status;
public static void main(String[] argv) throws IOException
InetAddress clientAddr;
if(argv.length==0)
clientAddr=InetAddress.getLocalHost();
else
clientAddr=InetAddress.getByName(argv[0]);
System.out.println("Connecting to Chat Server at "+clientAddr);
ChatApplet ca=new ChatApplet(clientAddr);
// ca.show();
Thread t=new Thread(ca);
t.start();
public ChatApplet(InetAddress adx)
super("Chat Client");
//AWT
resize(300,400);
setLayout(new BorderLayout());
textArea=new TextArea(20,20);
textArea.setEditable(false);
comm=new TextField(30);
status=new Label("Please type in alias to Connect..");
add("North",comm);
add("Center",textArea);
add("South",status);
//CommandReader cr=new CommandReader(this);
//commReader=new Thread(cr);
command="xXx";
try
socket=new Socket(adx,portNumber);
input=new DataInputStream(socket.getInputStream());
output=new PrintStream(socket.getOutputStream());
//commReader.start();
catch(IOException e)
status.setText("Abnormal chat client socket condition:"+e);
repaint();
public boolean action(Event e,Object o)
if(e.target==comm)
synchronized(command)
command=comm.getText();
comm.setText("");
return true;
return false;
public boolean handleEvent(Event evt)
if (evt.id == Event.WINDOW_DESTROY)
synchronized(command)
command="exit";
try
Class.forName(JDBC_DRIVER);
conn = DriverManager.getConnection(DATABASE_URL);
stat = conn.createStatement();
String ts = alias;//SHOULD DELETE IT FROM HERE
String ss = "delete from connected where name='"+ts+"'";
stat.executeUpdate(ss);
stat.close();
catch (Exception e)
System.out.println("Error at "+e);
/*if (evt.id == Event.ACTION_EVENT)
String text = textField.getText();
textArea.appendText(text + "\n");
textField.selectAll();
return super.handleEvent(evt);
public void run()
show();
try
doLoop();
input.close();
output.close();
socket.close();
System.exit(0);
catch(IOException e)
status.setText("Abnormal chat client socket condition:"+e);;
repaint();
public void doLoop() throws IOException
String nullString=new String("xXx");
String data=nullString;
while(true)
synchronized(command)
//System.out.println("Leggo synch");
if(!command.equals("xXx"))
data=command;
//reset
command="xXx";
//System.out.println("Leggo e prendo");
} //end synch
if(!data.equals("xXx"))
if(logging)
//il primo messaggio
logging=false;
alias=data;
status.setText("Logging as:"+alias);
repaint();
output.println("S"+alias); //Starting new chat
else
status.setText("Sending msg:"+data);
textArea.appendText(">"+data+"\n");
repaint();
output.println("D"+data); //sending data
if(data.equals("exit"))
status.setText("Exiting Chat...");
repaint();
output.println("X"+alias);
break;
//System.out.println("read socket");
data=input.readLine();
if(!data.equals("xXx"))
//System.out.println(data);
textArea.appendText("<"+data+"\n");
repaint();
data=nullString;If that code is being called, you're probably not deleting because the WHERE clause isn't being satisfied.
If I were you, I'd separate all that database code into a single object, outside the applet, that I could test on the command line until I was sure it was perfect. Then I'd just have the applet instantiate it and call its methods.
Right now you've got too much going on: database, applet, etc. Start getting one piece working at a time. JMO - MOD -
Dear Sir,
I am student who are using JDeveloper 2.0 to develop my thesis project. I try to use the Oracle Thin JDBC to connect to the oracle 8 default database but "connection refused".
Please give me some advise to make it work.
Is there any error if the hostID I used is my computer name?
SID: ORCL PORT:1521
I am doing the web database applet, so the Oracle Thin JDBC driver will be the best choice, right?
Lastly, thanks a lot for paying attention to my problem.
nullIs there any error if the hostID I used is >my computer name?For the thin driver the simplest thing to do is to enter the IP address of the target machine (If you can successfully ping the computer name then that should work too).
In general ,make sure:
1. the database is up
2. the username/pwd ,SID & port are correct
I am doing the web database applet, so the >Oracle Thin JDBC driver will be the best >choice, right?Correct. The thin driver is the right choice for applets.
Regards,
Arun
Maybe you are looking for
-
Why do i have two user accounts?
I recently bought a MacBook Pro and I have two user accounts. The one that I created when I started computer the first time and one that was created when I did the migration assistant the following day. How do I merge the two? FYI...This is my first
-
Hi! I've just started university and have been wondering whether to get a Mac or PC (I already own a desktop Windows PC). After much thought, I've decided to go the Mac "ultrabook" way, namely the MBP 13'' Retina (I might still choose the MB Air...).
-
I started getting an error message when trying to use TM, the message reads that the sparsebundle could not be created (error 45) How do I fix this problem and return TM to working order?
-
Query regarding language Preferences
Hi All, I have a requirement where I need to add 2 drop down columns to the standard existing page and when language is changed in preferences then it should affect for the newly added columns. I have added the those 2 columns through personalization
-
I recently had to restore my Mac from a backup and DW 8 refuses to run. Message says to reinstall but I can't find my original cd's. Since it seems impossible to find a trial download to which I can apply my registration number I have to decide on wh