Found 33676 Articles for Programming

How to connect to PostgreSQL database using a JDBC program?

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

924 Views

PostgreSQL is an open source relational database management system (DBMS) developed by a worldwide team of volunteers. PostgreSQL is not controlled by any corporation or other private entity and the source code is available free of charge.PostgreSQL runs on all major operating systems, including Linux, UNIX (AIX, BSD, HP-UX, SGI IRIX, Mac OS X, Solaris, Tru64), and Windows. It supports text, images, sounds, and video, and includes programming interfaces for C / C++, Java, Perl, Python, Ruby, Tcl and Open Database Connectivity (ODBC).Download the latest version of postgresql- from postgresql-jdbc repository.Add downloaded jar file postgresql-(VERSION).jdbc.jar in your class path.ExampleFollowing JDBC program ... Read More

How to connect to HSQLDB database using a JDBC program?

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

877 Views

HSQLDB is a relational database management system implemented in pure Java. You can easily embed this database to your application using JDBC. Or you can use the operations separately.Installing HSQLDB:Download the latest version of HSQLDB database.Install HSQLDB following the steps given in HSQLDB Tutorial.Make sure that the HSQLDB database is up and running. The URL to connect to this database is jdbc:hsqldb:hsql://host_name/database_name and the driver class name is org.hsqldb.jdbc.JDBCDriver. Download the driver and set classpath to it.ExampleFollowing JDBC program establishes a connection with HSQL database.import java.sql.Connection; import java.sql.DriverManager; public class ConnectDatabase {    public static void main(String[] args) {   ... Read More

How to get the current value of a particular row from a database using JDBC?

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

1K+ Views

The refreshRow() method of the ResultSet interface refreshes the current row with the most recent value in the database.rs.refreshRow()Assume we have a table named cricketers_data with 7 records as shown below:+----+------------+------------+---------------+----------------+-------------+ | ID | First_Name | Last_Name  | Year_Of_Birth | Place_Of_Birth | Country     | +----+------------+------------+---------------+----------------+-------------+ | 1  | Shikhar    | Dhawan     | 1981-12-05    | Delhi          | India       | | 2  | Jonathan   | Trott      | 1981-04-22    | CapeTown       | SouthAfrica | | 3  | Lumara     | Sangakkara | ... Read More

Ways to copy a vector in C++

Nishu Kumari
Updated on 30-Jan-2025 14:45:41

13K+ Views

In C++, vectors are commonly used to store dynamic collections of data. Sometimes, we need to copy a vector to manipulate data without affecting the original. In this article, we'll show you the easiest ways to copy a vector in C++, along with examples to show you how it works. Ways to copy a vector in C++ There are different ways to copy a vector in C++, and each method has its own use. We'll cover the following approaches: Using std::copy Using assign() Method By assignment "=" ... Read More

How to move the pointer of a ResultSet to the end of the table using JDBC?

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

133 Views

The afterLast() method of the ResultSet interface moves the cursor/pointer after the last row of the ResultSet object.rs.afterLast();Assume we have a table name dataset as shown below:+--------------+-----------+ | mobile_brand | unit_sale | +--------------+-----------+ | Iphone       | 3000      | | Samsung      | 4000      | | Nokia        | 5000      | | Vivo         | 1500      | | Oppo         | 900       | | MI           | 6400      | | MotoG   ... Read More

LongStream range() method in Java

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

514 Views

The range() method of the LongStream class in Java returns a sequential ordered LongStream from startInclusive to endExclusive by an incremental step of 1. This is inclusive of the initial element and exclusive of the last element.The syntax is as follows:static LongStream range(long startInclusive, long endExclusive)Here, startInclusive is the first value, whereas the endExclusive is the last.To use the LongStream class in Java, import the following package:import java.util.stream.LongStream;The following is an example to implement LongStream range() method in Java:Example Live Demoimport java.util.stream.LongStream; public class Demo {    public static void main(String[] args) {       LongStream longStream = LongStream.range(20L, 25L); ... Read More

How to move the pointer of a ResultSet to the default position using JDBC?

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

620 Views

The beofreFirst() method of the ResultSet interface moves the cursor/pointer to its default position i.e. before the first record.rs.beforeFirst();Assume we have a table named cricketers_data with 6 records as shown below:+----+------------+------------+---------------+----------------+-------------+ | ID | First_Name | Last_Name  | Year_Of_Birth | Place_Of_Birth | Country     | +----+------------+------------+---------------+----------------+-------------+ | 1 | Shikhar     | Dhawan     | 1981-12-05    | Delhi          | India       | | 2 | Jonathan    | Trott      | 1981-04-22    | CapeTown       | SouthAfrica | | 3 | Lumara      | Sangakkara ... Read More

The clear() method of CopyOnWriteArrayListin Java

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

96 Views

To remove all the elements from the CopyOnWriteArrayList, use the clear() method. It empties the list.The syntax is as follows:void clear()To work with CopyOnWriteArrayList class, you need to import the following package:import java.util.concurrent.CopyOnWriteArrayList;The following is an example to implement CopyOnWriteArrayList class clear() method in Java:Example Live Demoimport java.util.concurrent.CopyOnWriteArrayList; public class Demo {    public static void main(String[] args) {       CopyOnWriteArrayList arrList = new CopyOnWriteArrayList();       arrList.add(220);       arrList.add(250);       arrList.add(400);       arrList.add(500);       arrList.add(650);       arrList.add(700);       arrList.add(800);       System.out.println("CopyOnWriteArrayList String Representation ... Read More

The add() method of Java AbstractSequentialList class

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

100 Views

The AbstractSequentialList class has the add(int index, E ele) method to add element to the specific position. You can also use the add() method inherited from AbstractList class.add(int index, E ele) methodThe syntax is as follows:add(int index, E ele)Here, index is where the element is to be inserted. The ele is the element to be inserted.To work with the AbstractSequentialList class in Java, you need to import the following package:import java.util.AbstractSequentialList;The following is an example to implement AbstractSequentialList add() method in Java:Example Live Demoimport java.util.LinkedList; import java.util.AbstractSequentialList; public class Demo {    public static void main(String[] args) {       ... Read More

How to insert a row into a ResultSet object using JDBC?

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

413 Views

The insertRow() method of the ResultSet interface inserts a new row into the ResultSet object as well as the table.//Deleting a column from the ResultSet object rs.insertRow();Assume we have a table named cricketers_data with 6 records as shown below:+----+------------+------------+---------------+----------------+-------------+ | ID | First_Name | Last_Name  | Year_Of_Birth | Place_Of_Birth | Country     | +----+------------+------------+---------------+----------------+-------------+ | 1  | Shikhar    | Dhawan     | 1981-12-05    | Delhi          | India       | | 2  | Jonathan   | Trott      | 1981-04-22    | CapeTown       | SouthAfrica | | ... Read More

Advertisements