- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- 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
Found 317 Articles for JDBC
362 Views
The ResultSet class doesn’t provide any direct method to get the number of records in a table.The beforeFirst() method navigates the pointer/curser of the ResultSet object to its default position before first.In the same way the last() method positions the cursor at the last row of the ResultSet object.Using these methods you can find the number of records in the current ResultSet object.ExampleAssume we have a table named customers table with contents as shown below:+----+---------+-----+---------+----------------+ | ID | NAME | AGE | SALARY | ADDRESS | +----+---------+-----+---------+----------------+ | 1 | Amit | 25 | 3000.00 ... Read More
738 Views
When you set a save point you define a logical rollback point within a transaction. If an error occurs past a save point, you can use the rollback method to undo either all the changes or only the changes made after the save point.Savepoint interface gives you the additional transactional control. Most modern DBMS, support save points within their environments such as Oracle's PL/SQL.Setting a save pointYou can set a save point in a database using the setSavepoint(String savepointName) method of the Connection interface, this method accepts a string value representing the name of the save point and returns a ... Read More
6K+ Views
You can insert null values into a table in SQL in two ways:Directly inserting the value NULL into the desired column as:Insert into SampleTable values (NULL);Using ‘ ’ as nullInsert into SampleTable values (NULL);While inserting data into a table using prepared statement object you can set null values to a column using the setNull() method of the PreparedStatement interface.pstmt.setNull(parameterIndex, sqlType);ExampleAssume we have a table named cricketers_data in the database with the following contents:+------------+------------+---------------+----------------+-------------+ | First_Name | Last_Name | Date_Of_Birth | Place_Of_Birth | Country | +------------+------------+---------------+----------------+-------------+ | Shikhar | Dhawan | 1981-12-05 | ... Read More
513 Views
You can add/set an auto increment constraint to a column in a table using the ALTER TABLE command.SyntaxALTER TABLE table_name ADD id INT PRIMARY KEY AUTO_INCREMENTAssume we have a table named Dispatches in the database with 7 columns namely id, CustomerName, DispatchDate, DeliveryTime, Price and, Location with description as shown below:+--------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------------+--------------+------+-----+---------+-------+ | ProductName | varchar(255) | YES | UNI | NULL | | | CustomerName | varchar(255) | YES | ... Read More
254 Views
You can drop a constraint on a column of a table using the ALTER TABLE command.SyntaxALTER TABLE table_name DROP CONSTRAINT MyUniqueConstraint;Assume we have a table named Dispatches in the database with 7 columns namely id, CustomerName, DispatchDate, DeliveryTime, Price and, Location with description as shown below:+--------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------------+--------------+------+-----+---------+-------+ | ProductName | varchar(255) | YES | UNI | NULL | | | CustomerName | varchar(255) | YES | | NULL | ... Read More
327 Views
You can add a not null constraint to a column of a table using the ALTER TABLE command.SyntaxALTER TABLE table_name MODIFY column_name datatype NOT NULL;Assume we have a table named Dispatches in the database with 7 columns namely id, CustomerName, DispatchDate, DeliveryTime, Price and, Location with description as shown below:+--------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------------+--------------+------+-----+---------+-------+ | ProductName | varchar(255) | YES | | NULL | | | CustomerName | varchar(255) | YES | | NULL ... Read More
444 Views
You can add a unique constraint to a column using the ALTER TABLE commandSyntaxALTER TABLE table_name ADD CONSTRAINT MyUniqueConstraint UNIQUE(column1, column2...);Assume we have a table named Dispatches in the database with 7 columns namely id, CustomerName, DispatchDate, DeliveryTime, Price and, Location with description as shown below:+--------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------------+--------------+------+-----+---------+-------+ | ProductName | varchar(255) | YES | | NULL | | | CustomerName | varchar(255) | No | | NULL ... Read More
584 Views
You can add a primary key constraint to a column of a table using the ALTER TABLE command.SyntaxALTER TABLE table_name ADD CONSTRAINT MyPrimaryKey PRIMARY KEY (column1, column2...);Assume we have a table named Dispatches in the database with 7 columns namely id, CustomerName, DispatchDate, DeliveryTime, Price and, Location with description as shown below:+--------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------------+--------------+------+-----+---------+-------+ | ProductName | varchar(255) | YES | | NULL | | | CustomerName | varchar(255) | ... Read More
606 Views
You can delete a column in a table using the ALTER TABLE command.SyntaxALTER TABLE table_name DROP COLUMN column_name;Assume we have a table named Sales in the database with 7 columns namely id, CustomerName, DispatchDate, DeliveryTime, Price and, Location as shown below:+----+-------------+--------------+--------------+--------------+-------+----------------+ | id | productname | CustomerName | DispatchDate | DeliveryTime | Price | Location | +----+-------------+--------------+--------------+--------------+-------+----------------+ | 1 | Key-Board | Raja | 2019-09-01 | 08:51:36 | 7000 | Hyderabad | | 2 | Earphones | Roja | 2019-05-01 ... Read More
696 Views
You can change the datatype of a column in a table using the ALTER TABLE command.SyntaxALTER TABLE Sales MODIFY COLUMN column_name column_new_datatuypeAssume we have a table named Sales in the database with 7 columns namely ProductName, CustomerName, DispatchDate, DeliveryTime, Price, Location and, ID with description as:+--------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------------+--------------+------+-----+---------+-------+ | ProductName | varchar(255) | YES | | NULL | | | CustomerName | varchar(255) | YES | | NULL ... Read More