Daniol Thomas has Published 197 Articles

Write an example JDBC program demonstrating the batch processing with CallableStatement object?

Daniol Thomas

Daniol Thomas

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

879 Views

Grouping related SQL statements into a batch and executing/submitting them at once is known as batch processing. The Statement interface provides methods to perform batch processing such as addBatch(), executeBatch(), clearBatch().Follow the steps given below to perform batch updates using the CallableStatement object:Register the driver class using the registerDriver() method ... Read More

What is the syntax for input parameters (variables) in a MySQL query?

Daniol Thomas

Daniol Thomas

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

2K+ Views

To set a variable in MySQL, you need to use the SET command. Following is the syntax:set @yourVariableName:=yourValue; select *from yourTableName where yourColumnName=@yourVariableName;Let us first create a table:mysql> create table DemoTable (    Id int,    FirstName varchar(20),    LastName varchar(20) ); Query OK, 0 rows affected (0.83 sec)Following is ... Read More

How do I find out whether the underlying database supports batch processing?

Daniol Thomas

Daniol Thomas

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

293 Views

Not all the databases support batch processing therefore before proceeding with batch updates in your application. You need to verify whether the database you are trying to communicate supports batch processing/batch updates or not.You can do so using the supportsBatchUpdates() method of the DatabaseMetaData interface.Follow the steps given below:Register the ... Read More

How to process SQL statements with JDBC explain with an example?

Daniol Thomas

Daniol Thomas

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

6K+ Views

To process an SQL statement, you need to follow the steps given below:Establish the connection.Create a statement.Execute the statement/query.Process the result.Close the connection.Establishing a ConnectionTo process SQL statements first of all you need to establish connection with the desired DBMS or, file System or, other data sources.To do so, Register ... Read More

What is RowId object in JDBC Explain?

Daniol Thomas

Daniol Thomas

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

635 Views

A RowId is a built-in type of SQL which is an address of a row in a table of a database. The RowId interface of the java.sql package maps with the SQL ROWID value.RowId values are unique for every row and they are the fastest way to access a row. ... Read More

Java Program to minus seconds and nanoseconds from Instant

Daniol Thomas

Daniol Thomas

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

263 Views

Let us first set an Instant:Instant now = Instant.ofEpochMilli(184142540078l);Let us now minus seconds from Instant:Instant resSeconds = now.minusSeconds(50);Let us now minus nanoseconds from Instant:Instant resNanoSeconds = now.minusNanos(10000);Exampleimport java.time.Instant; public class Demo {    public static void main(String[] args) {       Instant now = Instant.ofEpochMilli(184142540078l);       System.out.println(now); ... Read More

LocalTime format() method in Java

Daniol Thomas

Daniol Thomas

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

146 Views

The LocalTime can be formatted with the specified formatter using the format() method in the LocalTime class in Java. This method requires a single parameter i.e. the LocalTime object to be formatted and it returns the formatted LocalTime with the specified formatter.A program that demonstrates this is given as follows:Example Live ... Read More

How to handle Exceptions while working with JDBC applications?

Daniol Thomas

Daniol Thomas

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

214 Views

Whenever a JDBC application encounters an issue while executing SQL statements an SQLException is thrown.This class provides information on the errors that occur while interacting with the database.Following are the main methods of the SQLException class:Sr.NoMethod & Description1int getErrorCode()This method returns the exception code for the Exception occurred.2SQLException setNextException(SQLException ex)Using ... Read More

LocalTime from() method in Java

Daniol Thomas

Daniol Thomas

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

74 Views

An instance of a LocalTime object can be obtained from a Temporal object using the from() method in the LocalTime class in Java. This method requires a single parameter i.e. the Temporal object and it returns the LocalTime object that is obtained from the Temporal object.A program that demonstrates this ... Read More

MonthDay hashCode() method in Java

Daniol Thomas

Daniol Thomas

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

123 Views

The hash code value of the MonthDay can be obtained using the hashCode() method in the MonthDay class in Java. This method requires no parameters and it returns the hash code value of the MonthDay.A program that demonstrates this is given as followsExample Live Demoimport java.time.*; public class Demo {   ... Read More

Advertisements