Found 7442 Articles for Java

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

685 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

11K+ 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

How to set time zone in a JSP?

Samual Sam
Updated on 30-Jul-2019 22:30:25

763 Views

The tag is used to copy a time zone object into the specified scoped variable.AttributeThe tag has the following attributes −AttributeDescriptionRequiredDefaultValueTime zone to expose as a scoped or configuration variableYesNonevarName of the variable to store the new time zoneNoReplace defaultscopeScope of the variable to store the new time zoneNoPageExample JSTL fmt:setTimeZone Tag Date in Current Zone: Change Time Zone to GMT-8 Date in Changed Zone: The above code will generate the following result −Date in Current Zone: 23 September 2010 15:21:37 GST Change Time Zone to GMT-8 Date in Changed Zone: 23 September 2010 03:21:37 GMT-08:00

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

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

12K+ 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

How to use time zone in a JSP?

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

553 Views

The tag is used to specify the time zone that all tags within its body will use.AttributeThe tag has the following attributes −AttributeDescriptionRequiredDefaultValueTime zone to apply to the bodyYesNoneExample           JSTL fmt:timeZone Tag                                                                                                  Formatting:                                                                                                                                                                                                                                                                 The above code will generate the following result −Formatting: 23 September 2010 15:09:09 GST Etc/GMT+1222-Sep-2010 23:09:09Etc/GMT+1123-Sep-2010 00:09:09

What are the data types supported by JDBC?

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

261 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

2K+ 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.

How to use multiple resource bundle in same JSP?

Samual Sam
Updated on 30-Jul-2019 22:30:25

355 Views

The tag is used to load a resource bundle and stores it in the named scoped variable or the bundle configuration variable.AttributeThe tag has the following attributes −AttributeDescriptionRequiredDefaultbasenameBase name of the resource bundle family to expose as a scoped or a configuration variableYesNonevarName of the variable to store the new bundleNoReplace defaultscopeScope of the variable to store the new bundleNoPageExample           JSTL fmt:setBundle Tag                     The above code will generate the following result −One Two Three

Advertisements