import java.awt.*;
import java.sql.*;
import java.awt.event.*;
public class shares
{
public static void main(String[] arguments){
String P[]=new String[100];
String Co[]=new String[100];
String N[]=new String[100];
String Cu[]=new String[100];
String PA[]=new String[100];
String CoA[]=new String[100];
String NA[]=new String[100];
String CuA[]=new String[100];
int number_bef=0;
int number_aft=0;
int Hayleys_Amount =0;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection cc = DriverManager.getConnection("jdbc:odbc:me");
Statement ss = cc.createStatement();
ResultSet rec_bef = ss.executeQuery("select * from List order by Purchased_Date" );
while (rec_bef.next()) {
P[number_bef]=rec_bef.getString("Purchased_Date");
Co[number_bef]=rec_bef.getString("Company");
N[number_bef]=rec_bef.getString("Number_of_Shares");
Cu[number_bef]=rec_bef.getString("Current_Price");
number_bef++;
}
rec_bef.close();
ss.executeUpdate("insert into List (Purchased_Date, Company, Number_of_Shares, Current_Price) values ('Dec 28, 2003', 'Vanik(NV)', '1350','2')");
ss.executeUpdate("delete * from List where Purchased_Date='Jan 21, 2000'");
ResultSet rec_aft = ss.executeQuery("select * from List order by Purchased_Date" );
while (rec_aft.next()) {
PA[number_aft]=rec_aft.getString("Purchased_Date");
CoA[number_aft]=rec_aft.getString("Company");
NA[number_aft]=rec_aft.getString("Number_of_Shares");
CuA[number_aft]=rec_aft.getString("Current_Price");
number_aft++;
}
rec_aft.close();
}catch (Exception e) {
System.out.println("ERROR: " + e.toString() +e.getMessage());
}
System.out.println(" ");
System.out.println("Purchased_Date, Company, Number_of_Shares,Current_Price");
for (int i=0; i<number_bef; i++){
System.out.println(P[i] + " , "+ Co[i] + " , " + N[i] + " , "+ Cu[i] + "." );
}
System.out.println(" ");
System.out.println("Inserted ('Dec 28, 2003', 'Vanik(NV)', '1350','2') and deleted Purchased_Date='Jan 21, 2000' ");
// PRINTING AFTER UPDATE
System.out.println("Purchased_Date, Company, Number_of_Shares, Current_Price");
for (int i=0; i<number_aft; i++){
System.out.println(PA[i] + " , " + CoA[i] + " , " + NA[i] + " , " + CuA[i] + "." );
String str="Hayleys";
if (CoA[i].equals(str))
Hayleys_Amount = Hayleys_Amount + (Integer.parseInt(NA[i])*Integer.parseInt(CuA[i]));
}
System.out.println("The current value of the Hayleys shares = " +Hayleys_Amount);
}
}
这是我的代码,当我尝试通过命令提示符运行小程序时,它说无法将共享转换为 java.applet.Applet 。请帮我弄清楚我的代码有什么问题。提前致谢。