java exception 行号_java – 允许范围以外的行号(65536)无效(0..65535)

该代码段展示了从Oracle数据库中查询数据,并将结果写入Excel文件的过程。在尝试将大量整数(约36000个)从文本文件读取作为查询参数时,遇到了Excel行数超出限制的问题,具体错误为'无效的行号(65536),超出允许范围(0..65535)'。这表明文件中的数据超过了Excel工作表的最大行数65536。
摘要由CSDN通过智能技术生成

我正在从文本文件中读取整数,将它们作为查询的输入,并获取查询输出并写入xls文件。

ResultSet rs;

Connection con = null;

PreparedStatement ps = null;

int person_org_id, external_person_org_id;

File f = null;

Scanner scan = null;

try {

System.out.println("----------checkpoint-----------");

Class.forName("oracle.jdbc.driver.OracleDriver");

System.out.println("----------checkpoint 1-----------");

con = DriverManager.getConnection("jdbc:oracle:thin:@ksdjf.kjdlk.jkd.com:2222:edb", "aaaaa", "aaaa");

System.out.println("----------checkpoint 2 ----------");

if (con == null) {

System.out.println("unable to connect to database");

}

System.out.println("----------checkpoint 3::connected to database---------");

StringBuffer sql = new StringBuffer();

sql.append("select abd from edb.abd where customer_id=510 and person_org_id =? ");

ps = con.prepareStatement(sql.toString());

HSSFWorkbook wb = new HSSFWorkbook();

HSSFSheet sheet = wb.createSheet("Excel Sheet");

HSSFRow rowhead = sheet.createRow(0);

rowhead.createCell(0).setCellValue("ABC");

rowhead.createCell(1).setCellValue("DEF");

f = new File("/tmp/contacts.txt");

scan = new Scanner(f);

int index=1;

while (scan.hasNextInt()) {

person_org_id = scan.nextInt();

ps.setInt(1,person_org_id);

rs= ps.executeQuery();

while (rs.next()) {

external_person_org_id = rs.getInt(1);

HSSFRow row = sheet.createRow(index);

row.createCell(0).setCellValue(person_org_id);

row.createCell(1).setCellValue(external_person_org_id);

index++;

}

}

FileOutputStream fileOut = new FileOutputStream(new File("/tmp/External_contact_id.xls"));

wb.write(fileOut);

fileOut.close();

System.out.println("--------checkpoint 4:: writing data to xls completed------------");

}

catch (Exception e) {

System.out.println(e.getMessage());

}

我收到错误无效的行号(65536)超出允许范围(0..65535)

我的contacts.txt文件有大约36000个数字。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值