我已按照此website from content 5.3中提供的说明操作,但代码运行正常。
我的计划是制作一个jar文件(包含一个接口/ GUI),将该jar文件分发给用户,然后让所有读/写数据都来自一个excel文件。当我将excel文件放在本地驱动器中时它可以工作,但是当我将文件放在网络文件夹/服务器中时,java会产生一个问题:
java.exe遇到问题需要关闭。对不起 给您带来不便。
或
Java Result: -1073741811
有什么建议吗?谢谢
public class TestIntoExcel
{
public String s;
public double number;
public Date d;
public void display()throws ClassNotFoundException, SQLException
{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection writeConnection = DriverManager.getConnection
("jdbc:odbc:usersavedataODBC");
writeConnection.setReadOnly(false);
Statement writeStatement = writeConnection.createStatement();
writeStatement.executeUpdate("CREATE TABLE TEST_INSERT(COL1 INT,COL2 VARCHAR(10),COL3 DATE)");
PreparedStatement writeStatement2 =
writeConnection.prepareStatement("INSERT INTO TEST_INSERT(COL1,COL2,COL3)VALUES(?,?,?)");
for(int i = 0; i<3;i++)
{
writeStatement2.setDouble(1, i);
writeStatement2.setString(2, "Row" + i);
writeStatement2.setDate(3, new java.sql.Date(new Date().getTime()));
writeStatement2.execute();
}
String query = "select *from[TEST_INSERT]";
ResultSet rset = writeStatement.executeQuery(query);
//System.out.println(rset);
while(rset.next())
{
number = rset.getDouble("COL1");
s = rset.getString("COL2");
d = rset.getDate("COL3");
System.out.println(number+"\n"+s+"\n"+d);
}
writeStatement.close();
writeStatement2.close();
writeConnection.close();