Get Strings in Table Records That End with Numbers

Samual Sam
Updated on 30-Jul-2019 22:30:25

98 Views

You need to use REGEXP for this. The syntax is as follows −select *from yourTableName where yourColumnName REGEXP '[[:digit:]]$';To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table StringEndsWithNumber    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> UserId varchar(20),    -> UserName varchar(20)    -> ); Query OK, 0 rows affected (0.62 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into StringEndsWithNumber(UserId, UserName) values('123User', 'John'); Query OK, 1 row affected (0.18 sec) mysql> insert ... Read More

AutoFlush Attribute in JSP

Samual Sam
Updated on 30-Jul-2019 22:30:25

2K+ Views

The autoFlush attribute specifies whether the buffered output should be flushed automatically when the buffer is filled, or whether an exception should be raised to indicate the buffer overflow.A value of true (default) indicates automatic buffer flushing and a value of false throws an exception.The following directive causes the servlet to throw an exception when the servlet's output buffer is full −This directive causes the servlet to flush the output buffer when full −Usually, the buffer and the autoFlush attributes are coded on a single page directive as follows −

What is Batch Processing in JDBC

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

394 Views

Grouping related SQL statements into a batch and executing/submitting them at once is known as batch processing.While executing a set of statements one after other the execution switches from the database to program simultaneously.Using batch processing we can reduce this communication overhead and increase the performance of our Java application.For Example, if we have a table named Emp with the following description:+----------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------+--------------+------+-----+---------+-------+ | Name | varchar(255) | YES | ... Read More

DoubleStream noneMatch Method in Java

Ankith Reddy
Updated on 30-Jul-2019 22:30:25

129 Views

The noneMatch() method of the DoubleStream class returns true if none of the elements of this stream match the provided predicate.The syntax is as followsboolean noneMatch(DoublePredicate predicate)Here, predicate is a stateless predicate to apply to elements of this stream. To use the DoubleStream class in Java, import the following packageimport java.util.stream.DoubleStream;Create DoubleStream and add some elements to the streamDoubleStream doubleStream = DoubleStream.of(15.8, 28.7, 35.7, 48.1, 78.9);Now, TRUE is returned if none of the element match the conditionboolean res = doubleStream.noneMatch(num -> num > 90); The following is an example to implement DoubleStream noneMatch() method in JavaExample Live Demoimport java.util.*; import java.util.stream.DoubleStream; ... Read More

Find and Replace String in MySQL Database

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

3K+ Views

Use the replace() function to replace string in MySQL Database.The syntax is as followsUPDATE yourTableName SET yourColumnName=replace(yourColumnName, 'yourExistingValue', 'yourNewValue') WHERE >;To understand the above syntax, let us create a table. The query to create a table is as followsmysql> create table findAndReplaceDemo    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> StudentFirstName varchar(20)    -> ); Query OK, 0 rows affected (0.49 sec)Insert some records in the table using insert command.The query is as followsmysql> insert into findAndReplaceDemo(StudentFirstName) values('Carol'); Query OK, 1 row affected (0.15 sec) mysql> insert into findAndReplaceDemo(StudentFirstName) values('David'); Query OK, 1 row ... Read More

Hide ID from Aggregation

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

558 Views

To hide _id from aggregation, use the below syntax −db.yourCollectionName.aggregate(    {$project : {       _id : 0 ,       yourIncludeFieldName:1,       yourIncludeFieldName:1    }} ).pretty();To understand the above syntax, let us create a collection with the document. The query to create a collection with a document is as follows −> db.hideidDemo.insertOne({"UserName":"Larry", "UserAge":23, "UserCountryName":"US"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c92b02336de59bd9de06392") } > db.hideidDemo.insertOne({"UserName":"Chris", "UserAge":21, "UserCountryName":"AUS"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c92b03036de59bd9de06393") } > db.hideidDemo.insertOne({"UserName":"Robert", "UserAge":26, "UserCountryName":"UK"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c92b04036de59bd9de06394") }Display all documents ... Read More

Connect to HSQLDB Database Using JDBC Program

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

904 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

Read All Contacts in Android

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

4K+ Views

This example demonstrate about How to read all contacts in androidStep 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 list view.Step 3 − Add the following code to src/MainActivity.java import android.annotation.TargetApi; import android.content.ContentResolver; import android.content.pm.PackageManager; import android.database.Cursor; import android.os.Build; import android.os.Bundle; import android.provider.ContactsContract; import android.support.v4.app.ActivityCompat; import android.support.v7.app.AppCompatActivity; import android.widget.ArrayAdapter; import android.widget.ListView; import java.util.ArrayList; public class MainActivity extends AppCompatActivity {    public static final int ... Read More

Find Keys from a LinkedHashMap and Store in a List in Java

Samual Sam
Updated on 30-Jul-2019 22:30:25

190 Views

Let us first create a LinkedHashMap with key-value pair −Mapmap = new LinkedHashMap(); map.put("1", "Katie"); map.put("2", "Peter"); map.put("3", "Amy"); map.put("4", "Kane"); map.put("5", "Colin"); map.put("6", "Andre"); map.put("7", "Pollard"); map.put("8", "David"); map.put("9", "Jofra"); map.put("10", "Akila");Now, create a new List and store the keys in it for the above Map −Listlist = new ArrayList(); list.addAll(map.keySet());Example Live Demoimport java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; public class Demo {    public static void main(String[] args) {       Mapmap = new LinkedHashMap();       map.put("1", "Katie");       map.put("2", "Peter");       map.put("3", "Amy");       map.put("4", "Kane");     ... Read More

Select Rows Where First Digit is a Number from 0 to 9 in MySQL

Ankith Reddy
Updated on 30-Jul-2019 22:30:25

1K+ Views

To select only those rows where first digit is a number from 0 to 9, use RLIKE. Following is the syntax −select *from yourTableName where yourColumnName RLIKE '^[0-9]+'Let us first create a table −mysql> create table DemoTable (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    QuestionNumber varchar(200) ); Query OK, 0 rows affected (0.56 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(QuestionNumber) values('1Question'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable(QuestionNumber) values('Question2'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable(QuestionNumber) values('311Question'); Query OK, 1 row affected (0.13 sec) ... Read More

Advertisements