当前位置: 技术问答>java相关
JSP如何写和读大字段
来源: 互联网 发布时间:2015-10-21
本文导语: 有时要把比较多的内容写入数据库中,不如SQL SERVER 的 text 类型的字段,要怎样写进去和读出来? | String sSql = "INSERT INTO news VALUES(?,?,?,?,?)"; PreparedStatement pstmt = con.pre...
有时要把比较多的内容写入数据库中,不如SQL SERVER 的 text 类型的字段,要怎样写进去和读出来?
|
String sSql = "INSERT INTO news VALUES(?,?,?,?,?)";
PreparedStatement pstmt = con.prepareStatement(sSql);
String title=request.getParameter("bt");
String new1=request.getParameter("new");
String sta=request.getParameter("sta");
String content=request.getParameter("txt1");
byte[] pic = content.getBytes("8859_1");
ByteArrayInputStream baisss = new ByteArrayInputStream(pic);
InputStreamReader bais = new InputStreamReader(baisss,"8859_1");
pstmt.setInt(1,id);
pstmt.setString(2,title);
pstmt.setCharacterStream(3,bais,pic.length);
pstmt.setString(4,new1);
pstmt.setString(5,sta);
pstmt.execute();
PreparedStatement pstmt = con.prepareStatement(sSql);
String title=request.getParameter("bt");
String new1=request.getParameter("new");
String sta=request.getParameter("sta");
String content=request.getParameter("txt1");
byte[] pic = content.getBytes("8859_1");
ByteArrayInputStream baisss = new ByteArrayInputStream(pic);
InputStreamReader bais = new InputStreamReader(baisss,"8859_1");
pstmt.setInt(1,id);
pstmt.setString(2,title);
pstmt.setCharacterStream(3,bais,pic.length);
pstmt.setString(4,new1);
pstmt.setString(5,sta);
pstmt.execute();
|
sql server 的确存在这样问题
VARCHAR类型存储的相对多些!
VARCHAR类型存储的相对多些!