Only for reference.
import java.io.File; import java.io.FileOutputStream; import java.io.InputStream; import java.sql.*; public class TestOperBlob { private static String url = "jdbc:oracle:thin:@localhost:1521:orcl"; private static String username = "test"; private static String password = "test"; public void queryBlob(){ try{ conn = getConnection(); conn.setAutoCommit(false); String sql = "INSERT INTO pictures (name, description, image) VALUES (?, ?, ?)"; PreparedStatement stmt = conn.prepareStatement(sql); stmt.setString(1, "java.gif"); stmt.setString(2, "Java Official Logo"); File image = new File("D:\\Projects\\kodejava\\web\\images\\java.gif"); fis = new FileInputStream(image); stmt.setBinaryStream(3, fis, (int) image.length()); stmt.execute(); conn.commit(); } catch (SQLException e) { e.printStackTrace(); } finally { closeConnection(conn); } } public void insertBlob(){ Connection conn = null; try { conn = getConnection(); String sql = "SELECT name, description, image FROM pictures "; PreparedStatement stmt = conn.prepareStatement(sql); ResultSet resultSet = stmt.executeQuery(); while (resultSet.next()) { String name = resultSet.getString(1); System.out.println("Name = " + name); String description = resultSet.getString(2); System.out.println("Description = " + description); File image = new File("D:\\java.gif"); FileOutputStream fos = new FileOutputStream(image); byte[] buffer = new byte[256]; // Get the binary stream of our BLOB data InputStream is = resultSet.getBinaryStream(3); while (is.read(buffer) > 0) { fos.write(buffer); } fos.close(); } } catch (SQLException e) { e.printStackTrace(); } finally { if (fis != null) { fis.close(); } closeConnection(conn); } } private static Connection getConnection() throws Exception { Connection connection = null; Class.forName("com.mysql.jdbc.Driver"); connection = DriverManager.getConnection(url, username, password); return connection; } private static void closeConnection(Connection connection) throws SQLException { if (connection != null && !connection.isClosed()) { connection.close(); } } public static void main(String[] args) throws Exception { queryBlob(); insertBlob(); } }
相关推荐
Blobs
AN12554 Demo Application to Generate Red/Black Blobs Using CAAM and Encrypt/Decrypt Data
Using Firebird Maestro you can operate database objects, build queries visually, represent databases as ER diagrams, execute queries and SQL scripts, view and edit data including BLOBs, represent ...
shsh(iphone3,2) iPhone_4-6.1.2_(10B146)-blobs.ifaith
matlab开发-从abinaryImage中删除blobs。“bwremove”删除种子映像中与掩码映像中的blob重叠的blob
access to their data from anywhere at any time and only pay for what they use and store. In WAS, data is stored durably using both local and geographic replication to facilitate disaster recovery. ...
WAS customers have access to their data from anywhere at any time and only pay for what they use and store. In WAS, data is stored durably using both local and geographic replication to facilitate ...
000000C85015A34F_iPhone_4-6.1.3_(10B329)-blobs.ifaith
and reduces their effective-replication-factor from 3.6 to either 2.8 or 2.1. f4 provides low latency; is resilient to disk, host, rack, and datacenter failures; and provides sufficient throughput for...
Bug with data type mapping from MONEY type to TBCDField field is fixed Bug with AV failure on project compilation in Delphi 7 is fixed MySQL data provider Bug with memory leaks on application ...
Bug with data type mapping from MONEY type to TBCDField field is fixed Bug with AV failure on project compilation in Delphi 7 is fixed MySQL data provider Bug with memory leaks on application ...
Supports terabyte-sized databases and gigabyte-sized strings and blobs. Self-contained: no external dependencies, no DLLs. Small footprint and smart linking: Only required code is compiled in, adding ...
降级必备,000001FCEF08654C_iPhone_4-6.0.1_(10A523)-blobs
Supports terabyte-sized databases and gigabyte-sized strings and blobs. Self-contained: no external dependencies, no DLLs. Small footprint and smart linking: Only required code is compiled in, adding ...
Supports terabyte-sized databases and gigabyte-sized strings and blobs. Self-contained: no external dependencies, no DLLs. Small footprint and smart linking: Only required code is compiled in, adding ...
Archive output is based on TStream and writes directlyfiles (TFileStream), memory (TMemoryStream), or database BLOBs(TBlobStream). DIZipWriter's functionality is contained in its main class, ...
from sklearn.datasets import make_blobs data = make_blobs(n_samples=500, centers=5, random_state=8) X, y = data plt.scatter(X[:, 0], X[:, 1], c=y, cmap=plt.cm.spring, edgecolors='k') plt.show() * 2....
本资源包含Blobs 示例程序。 MATLAB是美国MathWorks公司出品的商业数学软件,用于算法开发、数据可视化、数据分析以及数值计算的高级技术计算语言和交互式环境,主要包括MATLAB和Simulink两大部分。
Supports terabyte-sized databases and gigabyte-sized strings and blobs. Self-contained: no external dependencies, no DLLs. * Small footprint: less than 300 KB code space only. * Full Text Search with ...
dynamic_odbc_class.zip A class to dynamically read data from any ODBC data source(27KB)<END><br>38,CenturyDateTables.zip SQL DDLs for creating table structures and inserting the data for a set ...