如何在jdbc中使用ResultSet.getBinaryStream()从所有列中获取值?
如何使用jdbc将整个表写入平面文件(文本文件)?到目前为止,我已经尝试了以下内容:
Statement statement = connection.createStatement();
ResultSet result = statement.executeQuery("SELECT * FROM tablename");
BufferedInputStream buffer;
FileOutputStream out = new FileOutputStream("flatfile.txt");
while(result.next() )
{
buffer = new BufferedInputStream(result.getBinaryStream("????") );
byte[] buf = new byte[4 * 1024]; //4K buffer
int len;
while( (len = buffer.read(buf, 0, buf.length) ) != -1 )
{
out.write(buf, 0, len );
}
}
out.close();
“????”只是我的占位符。我被困在什么作为论点传递上。