Found 4378 Articles for MySQL

What are Lob Data Types? What are the restrictions on these datatypes in JDBC?

Krantik Chavan
Updated on 30-Jul-2019 22:30:25

164 Views

A BLOB is binary large object that can hold a variable amount of data with a maximum length of 65535 charactersThese are used to store large amounts of binary data, such as images or other types of files.A CLOB stands for Character Large Object in general, an SQL Clob is a built-in datatype is used to store large amount of textual data. Using this datatype, you can store data up to 2, 147, 483, 647 characters.Blob and Clob data types together are known as LOB (Large Object) datatypes. Following are the restrictions on these datatypes.Cannot compare: We cannot compare CLOB ... Read More

What is the difference between BLOB and CLOB datatypes?

Krantik Chavan
Updated on 07-Jun-2020 07:10:46

12K+ Views

Blob and Clob together are known as LOB(Large Object Type). The following are the major differences between Blob and Clob data types.BlobClobThe full form of Blob is a Binary Large Object.The full form of Clob is Character Large Object.This is used to store large binary data.This is used to store large textual data.This stores values in the form of binary streams.This stores values in the form of character streams.Using this you can stores files like videos, images, gifs, and audio files.Using this you can store files like text files, PDF documents, word documents etc.MySQL supports this with the following datatypes:TINYBLOBBLOBMEDIUMBLOBLONGBLOBMySQL ... Read More

How can we retrieve file from database using JDBC?

Krantik Chavan
Updated on 27-Jun-2020 06:18:17

959 Views

The ResultSet interface provides the methods named getClob() and getCharacterStream() to retrieve Clob datatype, In which the contents of a file are typically stored.These methods accept an integer representing the index of the column (or, a String value representing the name of the column) and retrieves the value at the specified column.The difference is the getClob() method returns a Clob object and the getCgaracterStream() method returns a Reader object which holds the contents of the Clob datatype.ExampleAssume we have created a table named Articles in the database with the following description.+---------+--------------+------+-----+---------+-------+ | Field   | Type         ... Read More

How do we insert/store a file into MySQL database using JDBC?

Daniol Thomas
Updated on 30-Jul-2019 22:30:25

4K+ Views

In general, the contents of a file are stored under Clob (TINYTEXT, TEXT, MEDIUMTEXT, LONGTEXT) datatype in MySQL database.JDBC provides support for the Clob datatype, to store the contents of a file in to a table in a database.The setCharacterStream() method of the PreparedStatement interface accepts an integer representing the index of the parameter and, a Reader object as a parameter.And sets the contents of the given reader object (file) as value to the parameter (place holder) in the specified index.Whenever you need to send very large text value you can use this method.Storing text file using JDBC:If you need to ... Read More

Write an JDBC example to retrieve Clob value from a table using the getCharacterStream() method?

Daniol Thomas
Updated on 30-Jul-2019 22:30:25

489 Views

The ResultSet interface provides the method named getClob() to retrieve clob datatype from a table in a database. In addition to this it also provides a method named getCharacterStream()Like getClob() this method also accepts an integer representing the index of the column (or, a String value representing the name of the column) and retrieves the value at the specified column. The difference is unlike the getClob() method (which returns a Clob object) this method returns an object of the Reader class.ExampleAssume we have created a table named MyData in the database with the following description.+---------+--------------+------+-----+---------+-------+ | Field   | Type ... Read More

Write an JDBC example for inserting value for Clob data type into a table?

Daniol Thomas
Updated on 30-Jul-2019 22:30:25

2K+ Views

Assume we already have a table named MyData in the database with the following description.+---------+--------------+------+-----+---------+-------+ | Field   | Type | Null | Key | Default | Extra | +---------+--------------+------+-----+---------+-------+ | Name | varchar(255) | YES | | NULL | | | Article | longtext | YES | | NULL | | +---------+--------------+------+-----+---------+-------+If you need to insert ... Read More

What is JDBC Clob data type? how to store and read data from it?

Daniol Thomas
Updated on 30-Jul-2019 22:30:25

10K+ Views

CLOB stands for Character Large Object in general, an SQL Clob is a built-in datatype and is used to store large amount of textual data. Using this datatype, you can store data up to 2, 147, 483, 647 characters.The java.sql.Clob interface of the JDBC API represents the CLOB datatype. Since the Clob object in JDBC is implemented using an SQL locator, it holds a logical pointer to the SQL CLOB (not the data).MYSQL database provides support for this datatype using four variables.TINYTEXT: A CLOB type with a maximum of 28-1 (255) characters.TEXT: A CLOB type with a maximum of 216-1 ... Read More

What is JDBC Blob data type? how to store and read data from it?

Daniol Thomas
Updated on 30-Jul-2019 22:30:25

11K+ Views

A BLOB is binary large object that can hold a variable amount of data with a maximum length of 65535 characters.These are used to store large amounts of binary data, such as images or other types of files. Fields defined as TEXT also hold large amounts of data. The difference between the two is that the sorts and comparisons on the stored data are case sensitive on BLOBs and are not case sensitive in TEXT fields. You do not specify a length with BLOB or TEXT.Storing blob in to databaseTo store Blob datatype to database, using JDBC program follow the ... Read More

What are the data types supported by JDBC?

Daniol Thomas
Updated on 30-Jul-2019 22:30:25

192 Views

JDBC provides support for almost all the SQL datatypes Whenever the JDBC driver receives a call from a Java application it converts the Java datatypes in it to the corresponding SQL data types. The conversion process follows default mapping. Following is the list of data types supported by JDBC and their corresponding SQL datatypes.SQLJDBC/JavaVARCHARjava.lang.StringCHARjava.lang.StringLONGVARCHARjava.lang.StringBITbooleanNUMERICjava.math.BigDecimalTINYINTbyteSMALLINTshortINTEGERintBIGINTlongREALfloatFLOATfloatDOUBLEdoubleVARBINARYbyte[ ]BINARYbyte[ ]DATEjava.sql.DateTIMEjava.sql.TimeTIMESTAMPjava.sql.TimestampCLOBjava.sql.ClobBLOBjava.sql.BlobARRAYjava.sql.ArrayREFjava.sql.RefSTRUCTjava.sql.Struct

What is the use of setFetchSize() and setMaxRows() methods of the JDBC Statement Interface?

Daniol Thomas
Updated on 30-Jul-2019 22:30:25

1K+ Views

The setFetchSize(int) method defines the number of rows that will be read from the database when the ResultSet needs more rows. setFetchSize(int) affects how the database returns the ResultSet data.Whereas, setMaxRows(int) method of the ResultSet specifies how many rows a ResultSet can contain at a time. setMaxRows(int) affects the client side JDBC object.

Advertisements