Arushi has Published 155 Articles

How to retrieve the contents of a ResultSet from last to first in JDBC?

Arushi

Arushi

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

489 Views

ResultSet objectCertain SQL queries (especially SELECT) returns tabular data, In JDBC the object of the java.sql.ResultSet interface holds the tabular data returned by the methods that execute the statements which quires the database (executeQuery() method of the Statement interface in general).ResultSet Cursor/pointerThe ResultSet object has a cursor/pointer which points to ... Read More

How to move the ResultSet cursor to the last row in JDBC?

Arushi

Arushi

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

991 Views

Whenever we execute SQL statements using the executeQuery() method, it returns a ResultSet object which holds the tabular data returned by the SELECT queries (in general).The ResultSet object contains a cursor/pointer which points to the current row. Initially this cursor is positioned before first row (default position).You can move the cursor ... Read More

How do you check if a ResultSet is closed or not in JDBC?

Arushi

Arushi

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

2K+ Views

Whenever we execute SQL statements using the executeQuery() method, it returns a ResultSet object which holds the tabular data returned by the SELECT queries(in general).The ResultSet object contains a cursor/pointer which points to the current row. Initially this cursor is positioned before first row (default position).The isClosed() method of the ResultSet interface ... Read More

How to get all table names from a database using JDBC?

Arushi

Arushi

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

6K+ Views

You can get the list of tables in the current database in MySQL using the SHOW TABLES query.Show tables;Following JDBC program retrieves the list of tables in the database by executing the show tables query.Exampleimport java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; public class ListingTables {    public static void ... Read More

How to Maintain an open ResultSet after commit in JDBC?

Arushi

Arushi

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

477 Views

ResultSet holdability determines whether the ResultSet objects (cursors) should be closed or held open when a transaction (that contains the said cursor/ ResultSet object) is committed using the commit() method of the Connection interface.ResultSet interface provides two values to specify the holdability namely CLOSE_CURSORS_AT_COMMIT and HOLD_CURSORS_OVER_COMMITIf the holdability of the ... Read More

How to get the table name of the current ResultSet using JDBC?

Arushi

Arushi

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

2K+ Views

You can get the name of the table in the current ResultSet object using the getTableName() method of the ResultSetMetaData interface. This method accepts an integer value representing the index of a column and, returns a String value representing the name of the table that contains the given column.Let us create ... Read More

How to get Row and Column Count from ResultSet in JDBC

Arushi

Arushi

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

2K+ Views

Row countThe last() method of the ResultSet interface moves the cursor to the last row of the ResultSet and, the getRow() method returns the index/position of the current row.Therefore, to get the number of rows move the cursor to the last row using the last() method and get the position of that (last) row ... Read More

How to generate multiple insert queries via java?

Arushi

Arushi

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

3K+ Views

JDBC provides a mechanism known as batch processing, in which you can group a set of INSERT or, UPDATE or, DELETE commands (those produce update count value) and execute them at once. You can insert multiple records in to a table using this.Adding statements to the batchStatement, PreparedStatement and CallableStatement ... Read More

Collision-Free Protocols

Arushi

Arushi

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

12K+ Views

In computer networks, when more than one station tries to transmit simultaneously via a shared channel, the transmitted data is garbled. This event is called collision. The Medium Access Control (MAC) layer of the OSI model is responsible for handling collision of frames. Collision – free protocols are devised so ... Read More

How to drop a table from Oracle database using JDBC API?

Arushi

Arushi

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

182 Views

You can insert records into a table using the INSERT query.SyntaxINSERT INTO TABLE_NAME (column1, column2, column3, ...columnN) VALUES (value1, value2, value3, ...valueN); Or, INSERT INTO TABLE_NAME VALUES (value1, value2, value3, ...valueN);To insert a record into a table in a database using JDBC API you need to −Register the Driver: Register ... Read More

Advertisements