编写了一个客户端是applet的提交页面,服务器接受提交的数据然后添加到数据库中的程序,但是有三个问题.1>为什么我用jcreate等工具就不能javac,而只有在dos下用javac就可以编译,2>编译后的class在网页上不显示,必须在dos下用appletviewer才能查看小程序,3>提交到服务器端不能正常的插入数据.期待高人帮忙解答.谢谢!下面是源码.服务器端:
import java.sql.*;
import java.io.*;
import java.net.*;class Candidate implements Serializable
{
String candidateCode;
String employeeCode;
String interviewerName;
String testDate;
int candidateTestscore;
String interviewDate;
String Comments;
String Rating;
String Status;}class CandidateServer implements Runnable
{
ServerSocket server;
Socket fromClient;
Thread serverThread;
public CandidateServer()
{
try
{
server = new ServerSocket(1001);
serverThread = new Thread(this);
serverThread.start();
}
catch(Exception e)
{
System.out.println("Cannot start the thread" + e);
}
System.out.println("Server started...");
}
public static void main(String args[])
{
new CandidateServer(); } public void run()
{   
try
{
while(true)
{
//Listening to the clients request
fromClient = server.accept();
//Creating the connect object 
Connect con = new Connect(fromClient); 
}
}
catch(Exception e)
{
       System.out.println("Cannot listen to the client" + e);
}
}
}//Code for the connect class
class Connect 
{
Candidate data;
ObjectInputStream streamFromClient; public Connect(Socket inFromClient)
{
//Retrieving the clients stream
try
{
streamFromClient = new  ObjectInputStream(inFromClient.getInputStream());
try
{
//Retrieving the applicant details from the client
data = (Candidate)streamFromClient.readObject();
}
catch(InvalidClassException e)
{
System.out.println("Cannot serialize the  applicant class" + e);
}
catch(NotSerializableException e)
{
System.out.println("The object is not  serializable" + e);
}
catch(IOException e)
{
System.out.println("Cannot read from the  client stream" + e);
}
//Call the submit method
submit(); 
}
catch(Exception e)
{
System.out.println("Cannot get the client stream" + e);
} }//Code for the submit method
public void submit()
{
try
{ //Code for submiting the applicant details to the  //database
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con;
con = DriverManager.getConnection("jdbc:odbc:test","sa","");PreparedStatement stat = con.prepareStatement("insert into ExternalCandidate(candidateCode,employeeCode,interviewerName,testDate,candidateTestscore,interviewDate,Comments,Rating,Status) values(?,?,?,?,?,?,?,?,?)");
stat.setString(1,data.candidateCode);
stat.setString(2,data.employeeCode);
stat.setString(3,data.interviewerName);
stat.setString(4,data.testDate);
stat.setInt(5,data.candidateTestscore);
stat.setString(6,data.interviewDate);
stat.setString(7,data.Comments);
stat.setString(8,data.Rating);
stat.setString(9,data.Status);
stat.executeUpdate();
}
catch(Exception e)
{
System.out.println("Cannot insert the data in the table" + e);
}
}
}
下一个帖子是客户端的代码: