Connection reset by peer...
843854Mar 21 2003 — edited Mar 21 2003Hi,
I just wanted to know if anyone can tell me what this error message means, and perhaps give me a pointer to where im wrong...
It allso returns a stacktrace which points to the "con = DriverManager..." line...
I appreciate any help i can get in this matter, been struggeling with this for quite a few days now...
Applet-page is hosted on an Apache webserver (my webhosts server), which also run mysql and php... Not sure what versions thay use.
Thanks in advance
Morten Olsrud
Norway
Code:
----------------------------------------------------------------------
import java.applet.*;
import java.sql.*;
import java.awt.*;
import java.awt.event.*;
public class Chat extends Applet implements KeyListener
{
public TextArea text = null;
public TextField msg = null;
public List users = null;
private Statement stmt = null;
public ResultSet res = null;
public void init()
{
setLayout( new BorderLayout() );
text = new TextArea();
text.setEditable(false);
add( text, BorderLayout.CENTER );
msg = new TextField();
msg.addKeyListener(this);
add( msg, BorderLayout.SOUTH);
users = new List();
add( users, BorderLayout.EAST);
connect();
}
public void keyPressed( KeyEvent ke )
{
if(ke.getKeyText( ke.getKeyCode()).equals("Enter") && !msg.getText().equals(""))
{
text.setText( msg.getText() + "\n");
try
{
if(msg.getText().indexOf("select") == -1)
{
text.append( stmt.executeUpdate(msg.getText()) +" rows affected.\n" );
}
else
{
res = stmt.executeQuery(msg.getText() );
text.append("\n\n");
while( res.next() )
{
text.append( res.getString( 1 ) + "\n");
}
}
}
catch( Exception ex )
{
System.out.println( "Fatal error: " + ex.toString() +"\n");
ex.printStackTrace();
}
}
}
public void keyReleased( KeyEvent ke ){}
public void keyTyped( KeyEvent ke ){}
public void connect()
{
try
{
System.out.println( "Starting" );
Class.forName( "com.mysql.jdbc.Driver" ).newInstance();
Connection con = DriverManager.getConnection("jdbc:mysql://www.mydomain.com/mydbname","user","password" );
stmt = con.createStatement();
System.out.println( "Finished" );
}
catch( Exception ex )
{
System.out.println( "Fault" );
System.out.println( "Fatal error: " + ex.toString() +"\n");
ex.printStackTrace();
System.out.println( "Fault 2" );
}
}
}