JDBC

How to get column type of a column in a table with JDBC?

In the following example, all the Employee table column names and their data types are printed using methods of ResultSetMetaData like getColumnName() and getColumnType(). Example on column type JDBC

int getColumnCount(): Returns the number of columns of a table String getColumnName(int columnNumber): Returns the name of the column whose…

How to get the name of column in a table with JDBC?

Column name JDBC ResultSetMetaData interface comes with methods to know the metadata of a table. Metadata is knowing the number of columns, name of each column etc. Example (of column name JDBC) prints the first column name and all the column names of table Employee. Example on column name JDBC…

How to get number of columns in a table with JDBC?

Number of columns in table JDBC ResultSetMetaData interface includes many methods to find the metadata of a table like number of columns, name of each column etc. Following example prints the number of columns of table Employee. Example on number of columns in table JDBC

Database connection is obtained…

How to find number of rows in the ResultSet object?

Number of rows in table JDBC There is no direct method in JDBC. In JDBC 1.0, the only way available is using while loop with a counter as follows. Example on number of rows in table JDBC with JDBC 1.0 style

You used the above loop in Select Records…

JDBC ResultSet Enhancement Update Methods Example

ResultSet methods JDBC JDBC 2.0 ResultSet enhancement operations include the methods to update, insert or delete a record without writing the SQL commands. That is, SQL commands need not be known, of course for CRUD operations. This is the greatness of ResultSet methods JDBC. Example on ResultSet methods JDBC

Create Scrollable ResultSet Example JDBC

Scrollable ResultSet: JDBC 2.0 API ResultSet methods are used where the records are read in the reverse order and also reading the data of a specific record. Note: It is advised to go through the postings Scrollable ResultSet and ResultSet Types and Concurrency as they are used in this code.…

JDBC ResultSet Types and Concurrency

ResultSet Types Concurrency JDBC Overloaded createStatement() Method (knowledge required for ResultSet Types Concurrency JDBC). Before going into programming it is required to know more about createStatement() method of Connection interface. This method can have parameters. You know the following Statement object creation earlier. Statement stmt = con.createStatement(); The createStatement() method…

Scrollable ResultSet

You retrieved records from database earlier in Select Records Example by iterating the records with the ResultSet object as follows. In the same example, you also have seen the ResultSet cursor movement in while loop.

The above loop prints the records from top to bottom (from 1st record to…

Insert Update Delete Record JDBC

Infact, without closing Connection object, any number of operations can be performed on the database. Here, three operations, Insert Update Delete Record JDBC are performed in a single program. You have seen earlier inserting record, updating record and deleting record in separate programs. For basics, it is advised to go…

Retrieve File JDBC

You have seen earlier how to store a file in database table office. Let us retrieve the file (Retrieve File JDBC), "Expenditure.txt" from table and write into another file "Liabilities.txt". Example in Retrieve File JDBC

Insert File JDBC

To store a file in Oracle table though JDBC (Insert File JDBC) Before going into execution, create table by name office with columns FILEID (number) and FILENAME (CLOB). Example on Insert File JDBC

To write to a CLOB (Character Large Object) data type, The PreparedStatement interface comes with three…

Retrieve Image JDBC

In the previous code XXXXXX, an image of juggler.gif is inserted in the table marriage. In this program let us read and print. To print, either Frame or Applet window is required. Here, Retrieve Image JDBC, Frame is used.

Reading the image and printing is a round about process.…

Execute SQL Function CallableStatement JDBC

In the following program a function by name calculate() is executed from JDBC. The function includes one IN parameter, one OUT parameter and one return value (note that return value can be one only, but IN and INOUT can be of any number). CallableStatement along with PreparedStatement is fully discussed…