📄 showimage.java
字号:
package imagefile;import java.awt.*;import java.awt.event.*;import javax.swing.*;import com.borland.jbcl.layout.*;import java.sql.*;import java.util.*;import java.io.*;public class ShowImage extends JFrame { JPanel contentPane; JLabel jLabel1 = new JLabel(); XYLayout xYLayout1 = new XYLayout(); public ShowImage() { enableEvents(AWTEvent.WINDOW_EVENT_MASK); try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } private void jbInit() throws Exception { contentPane = (JPanel) this.getContentPane(); contentPane.setLayout(xYLayout1); String selectSQL = "select * from filetable where filename ='imagefile.jpg'"; Properties props = new Properties(); props.put("user", "scott"); props.put("password", "tiger"); props.put("server", "myoracle"); try{ Driver myDriver = (Driver) Class.forName("weblogic.jdbc.oci.Driver").newInstance(); Connection con = myDriver.connect("jdbc:weblogic:oracle" , props); con.setAutoCommit(false); PreparedStatement pstmt = con.prepareStatement(selectSQL) ; ResultSet rs = pstmt.executeQuery() ; rs.next() ; Blob blob = rs.getBlob("filedata") ; // Materialize BLOB onto client ImageIcon icon = new ImageIcon(blob.getBytes(1, (int)blob.length())) ; jLabel1.setIcon(icon); rs.close(); pstmt.close(); }catch(Exception e){e.printStackTrace();} this.setSize(new Dimension(400, 300)); this.setTitle("Frame Title"); contentPane.add(jLabel1, new XYConstraints(52, 40, 327, 225)); } //Overridden so we can exit when window is closed protected void processWindowEvent(WindowEvent e) { super.processWindowEvent(e); if (e.getID() == WindowEvent.WINDOW_CLOSING) { System.exit(0); } } public static void main(String[] args) { ShowImage showImage = new ShowImage(); showImage.setVisible(true); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -