Java advanced data type

xiaoxiao2021-03-06  39

BLOB:

Write:

FileInputStream FIS = New FileInputStream (file);

Pstmt.setBinaryStream (1, Fis, (int) file.length ());

... pstmt.close ();

fis.close ();

Read:

BLOB BLOB = rs.getblob ("photo");

Imageicon icon = new imageicon (blob.getbytes (1, (int) blob.length ())));

Jlabel LPhoto = New Jlabel (icon);

Setlayout (New GridLayout (1, 1));

Add (LPhoto);

CLOB:

Write:

FileInputStream FIS = New FileInputStream (file);

Pstmt.setasciistream (1, Fis, (int) file.length ());

Read:

Clob Clob = rs.getClob ("MEMO");

InputStreamReader in = New InputStreamReader (Clob.Getasciistream ());

Jtextarea text = new jtextarea (ReadString (in));

Setlayout (New GridLayout (1, 1));

Add (Text);

Public Static String ReadString (InputStreamReader in) throws ioException {

StringBuffer buf = new stringbuffer ();

Int n;

Char [] b = new char [1024];

While ((n = in.read (b))> 0)

BUF.Append (b, 0, n);

Return buf.tostring ();

}

转载请注明原文地址:https://www.9cbs.com/read-64376.html

New Post(0)