Found 4219 Articles for MySQLi

How to update the current delimiter in MySQL?

George John
Updated on 30-Jul-2019 22:30:25

231 Views

At first, let us determine the current delimiter in MySQL using the following syntax\sThe above syntax will let you know about the current delimiter. Let us implement the above syntax.The query is as followsmysql> \sThe following is the outputC:\Program Files\MySQL\MySQL Server 8.0\bin\mysql.exe Ver 8.0.12 for Win64 on x86_64 (MySQL Community Server - GPL) Connection id: 19 Current database: sample Current user: root@localhost SSL: Cipher in use is DHE-RSA-AES128-GCM-SHA256 Using delimiter: ; Server version: 8.0.12 MySQL Community Server - GPL Protocol version: 10 Connection: localhost via TCP/IP Insert id: 11 Server characterset: utf8 Db characterset: utf8 Client characterset: utf8 Conn. characterset: ... Read More

Priority of AND and OR operator in MySQL select query?

Chandu yadav
Updated on 06-Aug-2021 21:41:51

987 Views

The AND has the highest priority than the OR operator in MySQL select query.Let us check how MySQL gives the highest priority to AND operator.The query is as followsmysql> select 0 AND 0 OR 1 as Result;The following is the output+--------+ | Result | +--------+ | 1     | +--------+ 1 row in set (0.00 sec)If you are considering the OR operator has the highest priority then MySQL will wrap up the above query like this.The query is as followsselect 0 AND (0 OR 1) as ResultFirst, solve the 0 OR 1, this will give result 1. After that ... Read More

How to handle date in JDBC?

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

1K+ Views

You can insert date values in SQL using the date datatype, The java.sql.Date class maps to the SQL DATE type.The PreparedStatement interface provides a method named setDate(). Using this you can insert date into a table. This method accepts two parameters −An integer representing the parameter index of the place holder (?) to which we need to set date value.a Date object representing the date value to be passed. The constructor of java.sql.Date class accepts a variable of long type representing the number of milliseconds from the epoch (standard base time I.e. January 1, 1970, 00:00:00 GMT).ExampleAssume we have created ... Read More

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

490 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

Advertisements