Found 9150 Articles for Object Oriented Programming

How to retrieve auto-incremented value generated by Statement using JDBC?

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

286 Views

While creating a table, in certain scenarios, we need values to column such as ID, to be generated/incremented automatically. Various databases support this feature in different ways.In MySQL database you can declare a column auto increment using the following syntax.CREATE TABLE table_name(    ID INT PRIMARY KEY AUTO_INCREMENT,    column_name1 data_type1,    column_name2 data_type2,    column_name3 data_type3,    column_name4 data_type4,    ............ ........... );While inserting records in a table there is no need to insert value under the auto-incremented column. These will be generated automatically.For example, in a table if we have a column with name ID and data type ... Read More

How to retrieve auto-incremented value generated by PreparedStatement using JDBC?

Smita Kapse
Updated on 29-Jun-2020 13:17:46

3K+ Views

While creating a table, in certain scenarios, we need values to column such as ID, to be generated/incremented automatically. Various databases support this feature in different ways.In MySQL database you can declare a column auto increment using the following syntax.CREATE TABLE table_name(    ID INT PRIMARY KEY AUTO_INCREMENT,    column_name1 data_type1,    column_name2 data_type2,    column_name3 data_type3,    column_name4 data_type4,    ............ ........... );While inserting records in a table there is no need to insert value under the auto-incremented column. These will be generated automatically.For example, in a table if we have a column with name ID and data type ... Read More

Can we change return type of main() method in java?

Maruthi Krishna
Updated on 29-Jun-2020 13:05:29

3K+ Views

The public static void main() method is the entry point of the Java program. Whenever you execute a program in Java, the JVM searches for the main method and starts executing from it.You can write the main method in your program with return type other than void, the program gets compiled without compilation errors. But, at the time of execution JVM does not consider this new method (with return type other than void) as the entry point of the program.It searches for the main method which is public, static, with return type void, and a String array as an argument.public static int ... Read More

What are the differences between GridLayout and GridBagLayout in Java?

raja
Updated on 29-Apr-2025 19:16:31

8K+ Views

In Java, a GridLayout puts all the components in a rectangular grid and is divided into equal-sized rectangles, and each component is placed inside a rectangle whereas GridBagLayout is a flexible layout manager that aligns the components vertically and horizontally without requiring that the components be of the same size. Java GridLayout A GridLayout arranges the components in a rectangular grid. It arranges components in the cells, and each cell has the same size. Components are placed in columns and rows. GridLayout(int rows, int columns) takes two parameters that are a column and a row. Syntax The following is the ... Read More

How to read/retrieve data from Database to JSON using JDBC?

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

10K+ Views

A Json array is an ordered collection of values that are enclosed in square brackets i.e. it begins with ‘[’ and ends with ‘]’. The values in the arrays are separated by ‘, ’ (comma).Sample JSON array{    "books": [ Java, JavaFX, Hbase, Cassandra, WebGL, JOGL] }The json-simple is a light weight library which is used to process JSON objects. Using this you can read or, write the contents of a JSON document using Java program.JSON-Simple maven dependencyFollowing is the maven dependency for the JSON-simple library −           com.googlecode.json-simple       json-simple       ... Read More

Does main() method accept arguments other than string array, in java?

Maruthi Krishna
Updated on 29-Jun-2020 13:08:04

5K+ Views

The public static void main() method accepts an array of values of the type String Java from the user.public class{    public static void main(String[] args){    } }You can pass them at the time of execution right after the class name separated with spaces as −java ClassName 10 20 30And, in the program (from the main method) you can extract these values from the String array and use.ExampleFor example, you can use command line arguments to pass a and b in the above program as −public class Sample {    public static void main(String[] args){       int ... Read More

How to insert/store JSON array into a database using JDBC?

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

10K+ Views

A Json array is an ordered collection of values that are enclosed in square brackets i.e. it begins with ‘[’ and ends with ‘]’. The values in the arrays are separated by ‘, ’ (comma).Sample JSON array{    "books": [ Java, JavaFX, Hbase, Cassandra, WebGL, JOGL] }The json-simple is a light weight library which is used to process JSON objects. Using this you can read or, write the contents of a JSON document using Java program.JSON-Simple maven dependencyFollowing is the maven dependency for the JSON-simple library −           com.googlecode.json-simple       json-simple       ... Read More

How to Write/create a JSON array using Java?

Smita Kapse
Updated on 06-Sep-2023 21:23:55

49K+ Views

A JSON array is an ordered collection of values that are enclosed in square brackets i.e., it begins with '[' and ends with ']'. The values in the arrays are separated by ', ' (comma).Sample JSON array{    "books": [ Java, JavaFX, Hbase, Cassandra, WebGL, JOGL] }The JSON-simple is a light weight library which is used to process JSON objects. Using this you can read or, write the contents of a JSON document using Java program.JSON-Simple maven dependencyFollowing is the maven dependency for the JSON-simple library −           com.googlecode.json-simple       json-simple       ... Read More

How to Write/create a JSON file using Java?

Alshifa Hasnain
Updated on 07-May-2025 18:33:22

64K+ Views

In this article, we will learn to write/create a JSON file using Java. JSON has become the standard for data exchange for any kind of application. Java also has a collection of libraries helpful in creating and storing JSON files. JSON JSON or JavaScript Object Notation is a lightweight text-based open standard designed for human-readable data interchange. Conventions used by JSON are known to programmers, which include C, C++, Java, Python, Perl, etc. Sample JSON document Below is an example of a JSON file: { "book": [ { ... Read More

How to read/parse JSON array using Java?

Alshifa Hasnain
Updated on 05-May-2025 18:32:29

60K+ Views

In this article, we will learn to read/parse a JSON array using Java. A JSON array is an ordered collection of values that are enclosed in square brackets, i.e., it begins with ‘[’ and ends with ‘]’. The values in the arrays are separated by ‘, ’ (comma). Sample JSON array The following is the syntax for JSON array initialization: { books": [ Java, JavaFX, Hbase, Cassandra, WebGL, JOGL] } Reading (Parsing) JSON array in Java The following are the different approaches for reading/parsing a JSON array in Java: JSON-Simple maven dependency ... Read More

Advertisements