- Trending Categories
- Data Structure
- Operating System
- MS Excel
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is RowId object in JDBC Explain?
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. You cannot use this as a primary key of a table.
Retrieving RowId objects
You can retrieve the RowId of a particular row using the getRowId() method of the ResultSet, CallableStatement, PreparedStatement interfaces.
This method accepts a String value representing a column label or, an integer value representing the column index and returns the respective RowId object.
//Retrieving the RowId objects RowId rowId1 = rs.getRowId("Mobile_Brand"); RowId rowId2 = rs.getRowId("Unit_Sale");
Setting the RowId values to prepared statement
You can use this as a unique value representing each row. You can set it as a parameter in PreparedStatement using the setRowId() method. To this method, you need to pass an integer representing the parameter index at which you need to set RowId as a value.
RowId rowid = rs.getRowId("Mobile_Brand"); PreparedStatement pstmt = con.prepareStatement("insert into myTable values (?, ?, ?)"); pstmt.setRowId(1, rowId); pstmt.setString(2, "Raja"); pstmt.setString(3, "Hyderabad");
- Related Articles
- What is a RowSet object explain using a JDBC program?
- What is a CachedRowSet in JDBC? Explain?
- What is CONCUR_UPDATABLE ResultSet in JDBC? Explain?
- What is CONCUR_READ_ONLY ResultSet in JDBC? Explain?
- What is JDBC SQL Escape Syntax Explain?
- What are save points in JDBC? Explain?
- What are batch updates in JDBC? Explain?
- What is the MySQL datatype to store DATALINK object in JDBC
- What is Parameterized Batch Update in JDBC? Explain with an example?
- What is Result in JDBC? How to retrieve data from ResultSet object?
- What is JDBC?
- What is CLOSE_CURSORS_AT_COMMIT in JDBC?
- What is Statement in JDBC?
- What is PreparedStatement in JDBC?
- What is CallableStatement in JDBC?