Posts

Showing posts with the label input and output

How to retrieve images from database by using JDBC?

How to retrieve images from database table by using the JDBC table? To know about this topic follow the below lines,           For downloading images from database table we no need to create any databases or tables, but we should know the which table and which column contains the images to retrieve. Once you know the table and column to retrieve images, here is the program to retrieve the images from database table. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 package com . javatbrains . jdbc ; import java.io.File ; import java.io.FileNotFoundException ; import java.io.FileOutputStream ; import java.io.IOException ; import java.io.InputStream ; import java.io.OutputStream ; import java.sql.Connection ; import java.sql.DriverManager ; import java.sql.ResultSet ; import ja...

How to insert images into database using JDBC?

How to insert images into database table by using JDBC? To know about these topic follow the below lines,           Before going to write a JDBC program for inserting images into database table, we need to create a specific table for inserting images column datatype. For creating the database table, execute the below command in MySQL command prompt. 1 2 3 4 CREATE TABLE ` images ` ( ` image_id ` int ( 11 ) NOT NULL AUTO_INCREMENT, ` image_flag ` int ( 11 ) NOT NULL , ` image ` longblob NOT NULL , PRIMARY KEY ( ` image_id ` ));           After executing the above query in MySQL command prompt, execute the below query to know weather the above table query is created or not. 1 Show tables;            When you have executed the above query that will show you the list of table which all exists in the current database. Current tab...

Serialization and deserialization in java with examples

Serialization and Deserialization is one of the commonly used concept in java to store object in any other location like, File, DB, Cloud,...etc and vice versa is called as Deserialization. In other words, Java provides a mechanism called Serialization to persist Java object into a file, database, network, process or any other system. Serialization makes object into an ordered or Serialized stream of bytes. That includes the object data as well as object type of data stored. Before moving further in Serialization and Deserialization in java, have a look at Input and Output streams. If you need to make your object as Serialized, the object class should be implemented from Serializable interface. Serializable is one of the interface called as marker interface in java. Marker interface is nothing but an interface which has no methods or fields to implement but it will do some functionality. Serializable interface is part of java.io package in java. ObjectOutputStream and ObjectInputS...