成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

mysql插入Clob字段的實例

數據庫 MySQL
mysql插入Clob字段的方法未必人人都會,下面以實例的方式為您介紹mysql插入Clob字段是如何實現的,如果您對此有興趣的話,不妨一看。

如果要實現mysql插入Clob字段,應該采用什么方法呢?下面這個例子就將為您演示如何實現mysql插入Clob字段的方法,供您參考。

  1. import java.io.*;  
  2. import java.sql.*;  
  3.                                                                                  
  4. public class DBTest {  
  5.     public static void main(String[] args) {  
  6.         String driver = "com.mysql.jdbc.Driver";  
  7.         String url = "jdbc:mysql://localhost:3306/upload?useUnicode=true&characterEncoding=Big5";  
  8.         String user = "caterpillar";  
  9.         String password = "123456";  
  10.         try {  
  11.             Class.forName(driver);  
  12.             Connection conn = DriverManager.getConnection(url, user, password);  
  13.  
  14.               
  15.             File file = new File("./logo_phpbb.jpg");  
  16.             int length = (int) file.length();  
  17.             InputStream fin = new FileInputStream(file);  
  18.               
  19.             PreparedStatement pstmt = conn.prepareStatement(  
  20.                        "INSERT INTO files VALUES(?, ?)");  
  21.             pstmt.setString(1, "Logo");  
  22.             pstmt.setBinaryStream (2, fin, length);  
  23.             pstmt.executeUpdate();  
  24.             pstmt.clearParameters();  
  25.             pstmt.close();  
  26.             fin.close();  
  27.               
  28.             Statement stmt = conn.createStatement();  
  29.             ResultSet result = stmt.executeQuery("SELECT * FROM files");  
  30.             result.next();  
  31.             String description = result.getString(1);  
  32.             Blob blob = result.getBlob(2);  
  33.                
  34.             System.out.println("描述:" + description);  
  35.             FileOutputStream fout = new FileOutputStream("./logo_phpbb_2.jpg");                
  36.             fout.write(blob.getBytes(1, (int)blob.length()));  
  37.             fout.flush();  
  38.             fout.close();  
  39.                                                                                  
  40.             stmt.close();  
  41.             conn.close();  
  42.         }  
  43.         catch(ClassNotFoundException e) {  
  44.             System.out.println("找不到驅動");  
  45.             e.printStackTrace();  
  46.         }  
  47.         catch(SQLException e) {  
  48.             e.printStackTrace();  
  49.         }  
  50.         catch(IOException e) {  
  51.             e.printStackTrace();  
  52.         }  
  53.     }  
  54. }  
  55.  

mysql插入Clob字段的實例介紹。

 

 

【編輯推薦】

常見MySql字段的默認長度

mysql中int數據類型長度的問題

MySQL中INSERT的一般用法

修改mysql字段順序的方法

mysql添加刪除主鍵的方法

責任編輯:段燃 來源: 互聯網
相關推薦

2009-06-26 10:19:00

Clob字段Hibernate

2009-07-15 17:01:29

iBATIS操作CLO

2017-09-05 09:18:54

OracleCLOB大數據

2009-08-27 16:00:03

C#靜態字段C#實例字段

2010-06-28 09:59:47

SQL Server自

2010-09-13 14:57:29

2009-11-19 10:43:54

Oracle Clob

2010-11-22 11:55:23

MySQL字段

2010-11-23 15:27:00

MySQL添加字段

2010-09-03 11:16:54

SQL刪除

2010-03-30 13:49:15

Oracle clob

2010-11-22 12:14:55

MySQL字段

2010-11-22 12:59:30

MySQL字段

2025-01-08 12:36:52

2010-07-09 12:49:41

SQL Server自

2009-07-15 16:42:03

iBATIS讀寫CLO

2009-09-25 14:04:12

Hibernate讀取

2021-04-08 10:55:53

MySQL數據庫代碼

2010-05-27 09:38:59

MySQL Grant

2010-10-14 16:27:56

MySQL隨機查詢
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 欧美成人激情 | 久久免费高清视频 | 国产精品久久久亚洲 | 亚洲精品视频在线看 | 日韩视频一区 | 亚洲精品大全 | 久久久久久综合 | 国产a区| 91视频入口 | 久久91 | 精品一区二区在线观看 | 欧美jizzhd精品欧美巨大免费 | 午夜在线影院 | 久久青草av | 日本a级大片 | 久久久久国产精品午夜一区 | 免费看一级毛片 | 久久免费小视频 | 日韩视频一区在线观看 | 不卡在线视频 | 黑人巨大精品欧美一区二区免费 | 久久久久久亚洲国产精品 | 亚洲精品欧美一区二区三区 | 欧美一级网站 | 精品视频一二区 | 一区二区视频在线 | 中文字幕在线观看一区二区 | 久久丝袜视频 | 天天夜天天操 | 久久久国产精品 | 亚洲日日 | 欧美一区二区三区在线观看视频 | www.av在线 | 免费久久久久久 | 亚洲一区中文字幕 | 九九精品久久久 | www.午夜| 91精品国产91久久久久久不卞 | 亚洲精品影院 | 99精品国产一区二区三区 | 欧美亚洲一级 |