StringJoiner setEmptyValue Method in Java 8

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

366 Views

The setEmptyValue() method of the StringJoiner class in Java 8 sets the sequence of characters. These characters are to be used when determining the string representation of this StringJoiner and when it is empty. That would be none of the elements have been added.The syntax is as followspublic StringJoiner setEmptyValue(CharSequence emptyVal)Here, emptyVal are the characters to return as the value of an empty StringJoinerTo work with the StringJoiner in Java 8, import the following package.import java.util.StringJoiner;The following is an example to implement StringJoiner setEmptyValue() method in Java:Example Live Demoimport java.util.StringJoiner; public class Demo {    public static void main(String[] args) { ... Read More

Insert Record into a Database Table Using JDBC API

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

1K+ Views

A. You can insert records in to a table using the INSERT query.SyntaxINSERT INTO TABLE_NAME (column1, column2, column3, ...columnN) VALUES (value1, value2, value3, ...valueN); Or, INSERT INTO TABLE_NAME VALUES (value1, value2, value3, ...valueN);To insert a record into a table in a database using JDBC API you need to:Register the driver: 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 URL (String), username (String), password (String) as parameters to it.Create Statement: Create a Statement object using ... Read More

SQL Using C/C++ and SQLite

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

2K+ Views

In this section, you will learn how to use SQLite in C/C++ programs.InstallationBefore you start using SQLite in our C/C++ programs, you need to make sure that you have SQLite library set up on the machine. You can check SQLite Installation chapter to understand the installation process.C/C++ Interface APIsFollowing are important C/C++ SQLite interface routines, which can suffice your requirement to work with SQLite database from your C/C++ program. If you are looking for a more sophisticated application, then you can look into SQLite official documentation.Serial NoAPI & Description1sqlite3_open(const char *filename, sqlite3 **ppDb)This routine opens a connection to an SQLite ... Read More

Change Line Color in EditText

Arjun Thakur
Updated on 30-Jul-2019 22:30:25

4K+ Views

In some situations, we should change edit text bottom line color according to background color. This example demonstrate about how to change line color in EditText.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.         In the above code, we have taken edit text, To change line color use the following code for edit text -android:backgroundTint="@android:color/holo_green_light"We can change color as per project requirement. we have taken green color for sample.Step 3 ... Read More

Find If a Column is Auto Increment in MySQL

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

1K+ Views

To find if a column is auto_increment in MySQL, you can use the following syntax −select COLUMN_NAME from information_schema.columns where TABLE_SCHEMA='yourDatabaseName' and TABLE_NAME='yourTableName' and EXTRA like '%auto_increment%';Let us first create a table. Here, ClientId is set AUTO_INCREMENT −mysql> create table autoIncrementTableDemo    -> (    -> ClientId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> ClientName varchar(20),    -> ClientAge int,    -> ClientAddress varchar(100),    -> ClientCountryName varchar(100)    -> ); Query OK, 0 rows affected (0.61 sec)Now, let us find whether any of the column is auto_increment −mysql> select COLUMN_NAME from information_schema.columns where TABLE_SCHEMA='test' and TABLE_NAME='autoIncrementTableDemo' and EXTRA ... Read More

Format Date as Apr 19, 2019 1:27 PM in Java

Daniol Thomas
Updated on 30-Jul-2019 22:30:25

192 Views

To format and display datetime, you need to use DateTimeFormatter. The format style is MEDIUM and SHORT:DateTimeFormatter formatter = DateTimeFormatter .ofLocalizedDateTime(FormatStyle.MEDIUM, FormatStyle.SHORT);Display the formatted date:formatter.format(LocalDateTime.now()Exampleimport java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.time.format.FormatStyle; public class Demo {    public static void main(String[] args) {       DateTimeFormatter formatter = DateTimeFormatter .ofLocalizedDateTime(FormatStyle.MEDIUM, FormatStyle.SHORT);       System.out.println("Formatted Date = "+formatter.format(LocalDateTime.now()));    } }OutputFormatted Date = Apr 19, 2019, 1:27 PM

Prevent MySQL Double Insert and Duplicate Entry

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

975 Views

To prevent duplicate entry, add constraint UNIQUE. Let us first create a table −mysql> create table DemoTable (    Id int,    Name varchar(100) ); Query OK, 0 rows affected (0.79 sec)Here is the query to prevent MySQL double insert using UNIQUE −mysql> alter table DemoTable add constraint id_NameUnKey UNIQUE(Id, Name); Query OK, 0 rows affected (0.82 sec) Records: 0 Duplicates: 0 Warnings: 0Insert records in the table using insert command. When we will try to the same record again, then the “Duplicate entry” error will be visible −mysql> insert into DemoTable values(11, 'John'); Query OK, 1 row affected (0.18 ... Read More

Asymmetric Digital Subscriber Loop (ADSL)

Krantik Chavan
Updated on 30-Jul-2019 22:30:25

2K+ Views

Asymmetric Digital Subscriber Line (ADSL) is a type of broadband communications technology that transmits digital data at a high bandwidth over existing phone lines to homes and businesses.In order to access ADSL, a Digital Subscriber Line modem (DSL modem) is installed at the client side. The DSL modem sends data bits over the local loop of the telephone network. The local loop is a two – wire connection between the subscriber’s house and the end office of the telephone company. The data bits are accepted at the end office by a device called Digital Subscriber Line Access Multiplexer (DSLAM).Features of ... Read More

Using WHERE Clause in Android SQLite

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

2K+ Views

Before getting into example, we should know what sqlite data base in android is. SQLite is an open source SQL database that stores data to a text file on a device. Android comes in with built in SQLite database implementation. SQLite supports all the relational database features. In order to access this database, you don't need to establish any kind of connections for it like JDBC, ODBC etc.This example demonstrate about How to where Clause in Android sqlite.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create ... Read More

Enable WebView Safe Browsing in Android

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

819 Views

This example demonstrates How to enable webview safe browsing in android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml. In the above code, we have taken web view to show tutorialspoint.com.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.app.ProgressDialog; import android.os.Build; import android.os.Bundle; import android.support.annotation.RequiresApi; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.webkit.WebChromeClient; import android.webkit.WebSettings; import android.webkit.WebView; import android.widget.EditText; public class MainActivity extends AppCompatActivity {    @RequiresApi(api = Build.VERSION_CODES.P) ... Read More

Advertisements