使用jsp和oracle过程中遇到如下的问题
(1)在oracle中写存储过程并且在java中读取 发现没法用getString获取long类型.而一起取出的其他varchar2都能作为String值取出
String content=rs.getString("content"); //取不到值 显示null
问下如何做才能将long类型值取出 并且在一个textarea中显示?
(2)在jsp中我用String类型来获取textarea的值并且将其写入long字段。这样是可行的
cstmt.setString(9,content); //输入第九为long类型字段,content为字符串。
但是不知道这样输入会不会对输入的数据造成什么破坏。
是不是有更好的方法来将textarea的数据输入oracle的long字段。
Code for inserting Long Data
public void insertData(String code, String name, String partner,
String textfile) throws Exception {
// Create a File to read data from the specified text file (textfile)
File file =
new File(getClass().getClassLoader().getResource(textfile).getFile());
// Prepare the statement for inserting a row into the OTN_AIRLINES_LONG
PreparedStatement pstmt = connection.prepareStatement(" INSERT INTO "+
"otn_airlines_long( code, name, partner,"+
"airline_insurance_data) VALUES(?, ?, ?, ?)");
// Bind the parameter values for the above statement
pstmt.setString(1, code);
pstmt.setString(2, name);
pstmt.setString(3, partner);
// Bind the AIRLINE_INSURANCE_DATA column to an input Ascii stream that
// returns the Ascii data to be inserted into the LONGRAW column
pstmt.setCharacterStream(4, new FileReader(file), (int)file.length());
// Execute the statement
pstmt.execute();
}
}
................
................
Code for retrieving Long Data
public void displayLongData(String code) { |