gpt4 book ai didi

java - 查询和写入文件 : errorcode 28

转载 作者:行者123 更新时间:2023-11-29 07:12:37 25 4
gpt4 key购买 nike

当我尝试查询数据库并将结果写入文件时出现此错误。它以前从未发生过。

java.sql.SQLException: Error writing file '/tmp/MYwADPLw' (Errcode: 28)

at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:946) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2870) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1573) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1665) at com.mysql.jdbc.Connection.execSQL(Connection.java:3170) at com.mysql.jdbc.Connection.execSQL(Connection.java:3099) at com.mysql.jdbc.Statement.executeQuery(Statement.java:1169) at DBase.connect(DBase.java:58)
// this is where i call executequery at automateExport.main(automateExport.java:11) Exception in thread "main" java.lang.NullPointerException at automateExport.main(automateExport.java:13) // main class with db connection

我期望的结果集非常大。当我查询较小的结果集时,我从来没有遇到过这个问题。会不会是空间问题?我的光盘上有 117 GB。但我期望最多 1gb 的文本数据。有什么解决办法吗???

我的代码:

 public Connection connect(String db_connect_str,String db_userid, String db_password) {
Connection conn;
Statement stmt;
String query;
// inputfile - csv
String input = "inputfile.txt";
try {
// to bifurcate heap memory error
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection(db_connect_str,db_userid, db_password);
stmt = conn.createStatement(java.sql.ResultSet.TYPE_FORWARD_ONLY,
java.sql.ResultSet.CONCUR_READ_ONLY);
stmt.setFetchSize(Integer.MIN_VALUE);

query = "SELECT r.name, r.network , r.namestring, i.name, i.description "+
" , r.rid , i.id, d.dtime ,d.ifInOctets , d.ifOutOctets , FROM_UNIXTIME(d.dtime)"+
" FROM router AS r INNER JOIN interface AS i ON r.rid = i.rid " +
"INNER JOIN 1278993600_1_60 AS d ON i.id = d.id " +
"AND dtime BETWEEN " +startTime+ " AND "+ endTime +" WHERE r.network = 'ITPN'" +
"AND i.status = 'active' ORDER BY i.id, d.dtime";

BufferedWriter fw = new BufferedWriter(new FileWriter(input));
ResultSet rs = stmt.executeQuery(query);
String idescp = null;
// writing to file
while (rs.next()) {
if(rs.getString("description").equals(null)){
System.out.println("description" +rs.getString("description") );
idescp = "NA";
System.out.println("idescp :" +idescp + ":");
}else{
idescp = rs.getString("description");
}
fw.write(rs.getString(1)+","+ rs.getString("rid")+","+ rs.getString("id") + "," +idescp+","
+rs.getString("dtime")+ "," +rs.getString("ifInOctets")+ "," +
rs.getString("ifOutOctets") + ","+ rs.getString(11)+NL);
}

fw.close();
rs.close() ;
stmt.close() ;
} catch(Exception e) {
e.printStackTrace();
conn = null;
}
return conn;
}

请帮忙。谢谢。

最佳答案

也许数据库用完了文件上的临时空间。我会检查给定的路径、运行数据库的帐户是否有权限和空间来写入一些数据。

关于java - 查询和写入文件 : errorcode 28,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3533181/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com