Programming Articles - Page 2734 of 3366

How to connect to Derby database using a JDBC program?

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

2K+ Views

Apache Derby is a Relational Database Management System which is fully based on (written/implemented in) Java programming language. It is an open source database developed by Apache Software Foundation.Installing derby:Follow the steps given below to install derby:Visit the home page of Apache Derby home page https://db.apache.org/derby/. Click the Download tab.Select and click on the link of the latest version of Apache Derby.On clicking the selected link, you will be redirected to the Distributions page of apache derby. If you observe here, derby provides distributions namely, db-derby-bin, db-derbylib.zip, db-derby-lib-debug.zip, and db-derby-src.zip.Download the db-derby-bin folder. Copy its contents to a separate folder ... Read More

Understanding cin.clear() and cin.ignore() in C++

Revathi Satya Kondra
Updated on 11-Apr-2025 17:33:40

1K+ Views

When we attempt to work with user input in C++, unwanted behavior may be caused by errors or leftover characters in the input buffer. So, in that case cin.clear() and cin.ignore() are functions that can help in dealing with this kind of problem. cin.clear() cin.ignore() cin.clear and cin.ignore() cin.clear() The cin.clear() resets the error flags on the cin stream and is used when an input operation fails (e.g., entering a non-numeric value for an integer variable). Without clearing the error flags, further input operations will not work. ... Read More

How to connect to an SQLite database using a JDBC program?

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

2K+ Views

A. SQLite is an in-process library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine. It is a database, which is zero-configured, which means like other databases you do not need to configure it in your system.SQLite engine is not a standalone process like other databases, you can link it statically or dynamically as per your requirement with your application. SQLite accesses its storage files directly.The URL to connect with SQLite database is jdbc:sqlite:test.db and, the driver class name to connect to it is org.sqlite.JDBC.Before you proceed with the example:Download latest version of sqlite-jdbc-(VERSION).jar from sqlite-jdbcrepository.Add downloaded jar file ... Read More

C++ Program to Print only Odd Numbered Levels of a Tree

Revathi Satya Kondra
Updated on 11-Apr-2025 17:32:01

247 Views

In C++, to print the odd-numbered levels of a binary tree, the levels are numbered from the root as Level 1. The odd-numbered levels are Level 1, Level 3, and so on. This program prints the nodes present at these odd levels. It uses level-order traversal to process the tree level by level and prints the nodes found at these levels. Algorithm to Print only Odd Numbered Levels of a Tree Following is the Algorithm to print odd numbered levels of a tree − Create a structure for tree nodes with data and pointers to left ... Read More

Differences between pass by value and pass by reference in C++

Revathi Satya Kondra
Updated on 11-Apr-2025 22:19:12

24K+ Views

In C++, there are two main ways to pass arguments to functions: pass by value and pass by reference. When you use pass by value, a copy of the variable is made, so the original variable doesn't change. With pass by reference, the function works with the original variable, so it can be changed directly. Each method is used based on what you want the function to do. We can pass arguments into a function in different ways. These different ways are − Call by Value Call by Reference ... Read More

How to call an existing function in a database using JDBC API?

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

7K+ Views

You can call a function using CallableStatement object just like stored procedures, to call a function using a JDBC program you need to.Connect to the database.Create a PreparedStatement object and to its constructor pass the function call in String format.Set values to the place holders.Execute the Callable statement.Following is the query to call a function from JDBC:{? = call getDob(?)}As you observe the query contains place holders (?) just like prepared and callable statements.In the above query, the first place holder represents the return value of the function and the second placeholder represents the input parameter.You need to register the ... Read More

What do single quotes do in C++ when used on multiple characters?

Farhan Muhamed
Updated on 06-Jun-2025 18:59:11

980 Views

Single quotes in C++ are used to denote characters, not strings. When you use single quotes around multiple characters or strings, C++ compiler will treat it as a multi-character literal, which will be stored as an integer value, representing the combined ASCII values of those characters. In this article, we will learn all about single quotes in C++ and how they behave when used with multiple characters. Single Quotes in C++ In C++, single quotes are used to represent a single character. For example, 'a' is a character literal representing the english alphabet 'a'. For each character, C++ assigns a ... Read More

How to create a function in a database using JDBC API?

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

1K+ Views

Like procedures, you can also create function in a database and store them.SyntaxFollowing is the syntax of creating a function in a(MySQL) database:CREATE FUNCTION Function_Name(input_arguments) RETURNS output_parameter BEGIN declare variables; statements . . . . . . . . . . return data_type; ENDTo create a function in a database using JDBC API you need to:Register the driver: class using the registerDriver() method of the DriverManager class. Pass the driver class name to it, as parameter.Establish a connection: Connect ot the database using the getConnection() method of the DriverManager class. Passing ... Read More

Why does std::getline() skip input after a formatted extraction?

Farhan Muhamed
Updated on 06-Jun-2025 18:58:39

536 Views

When using std::getline after a formatted extraction (like std::cin >>), you might see an unexpected behavior, where std::getline is skipping the next input line. In this article, we will understand why this happens and how to handle it. Getline skipping input after formatted extraction The code below shows how getline() is skipping input after a formatted extraction: #include #include using namespace std; int main() { string name; string city; cin

How to call a stored procedure that returns output parameters, using JDBC program?

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

10K+ Views

A. Stored procedures are sub routines, segment of SQL statements which are stored in SQL catalog. All the applications that can access Relational databases (Java, Python, PHP etc.), can access stored procedures.Stored procedures contain IN and OUT parameters or both. They may return result sets in case you use SELECT statements. Stored procedures can return multiple result sets.You can call a stored procedure using the following syntax:CALL procedure_name (input_parameter1, input_parameter2, input_parameter3)JDBC provides a standard stored procedure SQL escape syntax using which you can procedures in all RDBMSsTo call a stored procedure using a JDBC program you need to:Register the driver: ... Read More

Advertisements