Use AppBar Layout in Android

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

3K+ Views

This example demonstrate about How to use appbar layout 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 app bar layout and recycler view.Step 3 − Add the following code to src/MainActivity.java import android.annotation.TargetApi; import android.app.Activity; import android.content.Intent; import android.content.SharedPreferences; import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.support.v4.content.pm.ShortcutInfoCompat; import android.support.v4.content.pm.ShortcutManagerCompat; import android.support.v4.graphics.drawable.IconCompat; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.DefaultItemAnimator; ... Read More

Syntax for Input Parameters in MySQL Query

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

2K+ Views

To set a variable in MySQL, you need to use the SET command. Following is the syntax:set @yourVariableName:=yourValue; select *from yourTableName where yourColumnName=@yourVariableName;Let us first create a table:mysql> create table DemoTable (    Id int,    FirstName varchar(20),    LastName varchar(20) ); Query OK, 0 rows affected (0.83 sec)Following is the query to insert some records in the table using insert command:mysql> insert into DemoTable values(10, 'Carol', 'Taylor'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values(20, 'John', 'Doe'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values(30, 'John', 'Smith'); Query OK, 1 row ... Read More

IntBuffer compareTo Method in Java

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

163 Views

A buffer can be compared with another buffer using the method compareTo() in the class java.nio.IntBuffer. This method returns a negative integer if the buffer is less than the given buffer, zero if the buffer is equal to the given buffer and a positive integer if the buffer is greater than the given buffer.A program that demonstrates this is given as follows −Example Live Demoimport java.nio.*; import java.util.*; public class Demo {    public static void main(String[] args) {       int n = 5;       try {          IntBuffer buffer1 = IntBuffer.allocate(n);     ... Read More

Subtract Content of Two Ports by Interfacing 8255 with 8085 Microprocessor

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

579 Views

In this program we will see how to perform subtraction by using ports to take data and send the result into the port.Problem StatementWrite 8085 Assembly language program for interfacing between 8085 and 8255. Here Port A and Port B are holding two values, take the numbers from port A and B, subtract B from A, and send the result at port C.DiscussionThe task is very simple. At first we have to setup the control word register of 8255 chip. After that we will take the input from port A and B, add the content, and send it to port ... Read More

Reverse a String in Android

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

1K+ Views

This example demonstrates How to do reverse of string 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 name and when user click on button it will print reverse of edittext value.Step 3 − Add the following code to src/MainActivity.javapackage com.example.andy.myapplication; import android.os.Bundle; ... Read More

What is isErrorPage Attribute in JSP

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

2K+ Views

The errorPage attribute tells the JSP engine which page to display if there is an error while the current page runs. The value of the errorPage attribute is a relative URL.The following directive displays MyErrorPage.jsp when all uncaught exceptions are thrown −The isErrorPage attribute indicates that the current JSP can be used as the error page for another JSP.The value of isErrorPage is either true or false. The default value of the isErrorPage attribute is false.For example, the handleError.jsp sets the isErrorPage option to true because it is supposed to handle errors −

Group Queries Using Transaction in JSP

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

268 Views

The tag is used to group the and tags into transactions. You can put as many and tags as statements inside the tag to create a single transaction.It ensures that the database modifications performed by the nested actions are either committed or rolled back if an exception is thrown by any nested action.AttributeThe tag has the following attributes −AttributeDescriptionRequiredDefaultdataSourceDatabase connection to use (overrides the default)NoDefault databaseisolationTransaction isolation (READ_COMMITTED, READ_UNCOMMITTED, REPEATABLE_READ, or SERIALIZABLE)NoDatabase’s defaultExampleTo start with the basic concept, let us create a Students table in the TEST database and create a few records ... Read More

DoubleStream mapToLong Method in Java

George John
Updated on 30-Jul-2019 22:30:25

143 Views

The mapToLong() method of the DoubleStream class returns a LongStream consisting of the results of applying the given function to the elements of this stream.The syntax is as followsLongStream mapToLong(DoubleToLongFunction mapper)Here, the parameter mapper is a stateless function to apply to each element. The DoubleToLongFunction here is a function that accepts a double-valued argument and produces a long-valued result.To use the DoubleStream class in Java, import the following packageimport java.util.stream.DoubleStream;Create a DoubleStream and add some elementsDoubleStream doubleStream = DoubleStream.of(30.5, 45.8, 89.3);Now, use the LongStream and set a condition for the stream elementsLongStream longStream = doubleStream.mapToLong(a -> (long)a); The following is ... Read More

Find and Replace String in MySQL Fields

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

344 Views

To find/replace string in fields, the syntax is as follows −update yourTableName set yourColumnName =REPLACE(yourColumnName, yourOldValue, yourNewValue);To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table FindReplaceDemo    -> (    -> FileId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> FileDirectory text    -> ); Query OK, 0 rows affected (0.92 sec)Now you can insert some records in the table using insert command. The query is as follows −mysql> insert into FindReplaceDemo(FileDirectory) values('C://User//MySQL'); Query OK, 1 row affected (0.19 sec) mysql> insert into FindReplaceDemo(FileDirectory) values('D://WebsiteImage//image1.jpg'); Query OK, ... Read More

Retrieve Multiple ResultSets from a Stored Procedure Using JDBC

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

6K+ Views

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.Retrieving Results from a procedure:You can call an existing stored procedure using the CallableStatement. The prepareCall() method of the Connection interface accepts the procedure call in string format and returns a callable statement object.CallableStatement cstmt = con.prepareCall("{call sampleProcedure()}");Execute the above created callable statement using ... Read More

Advertisements