To create database only once, use the below syntax.CREATE DATABASE IF NOT EXISTS yourDatabaseName;To create table only once, use the below syntax −CREATE TABLE IF NOT EXISTS yourTableName ( yourColumnName yourDatatype, . . . N );Let us implement both the above syntaxes to create database and table only once if does not already exist −mysql> CREATE DATABASE IF NOT EXISTS login; Query OK, 1 row affected (0.23 sec)Above query creates a database successfully.Following is the query to create a table −mysql> CREATE TABLE IF NOT EXISTS DemoTable ( Id int ); Query OK, 0 rows affected (0.56 sec)Above query creates a table successfully.
In MySQL, there are two approaches by which you can reset the MySQL field to default value. One is default keyword and another is default() function.Case 1: Using default keyword. The syntax is as follows:UPDATE yourTableName SET yourColumnName=default where yourCondition;Case 2: Using default() function. The syntax is as follows:UPDATE yourTableName SET yourColumnName=default(yourColumnName) where yourCondition;To understand the above syntax, let us create a table. The query to create a table is as follows:mysql> create table Default_Demo -> ( -> Id int NOT NULL AUTO_INCREMENT, -> Name varchar(20), -> Age int, -> Salary float, -> PRIMARY ... Read More
You can typecast with the help of method intValue(). The syntax is as follows −Integer yourVariableName=((BigInteger) yourBigIntegerValue).intValue();Here is the Java code to convert java.math.BigInteger cast to java.lang.Integer. The code is as follows −Example Live Demoimport java.math.BigInteger; public class BigIntegerToInteger { public static void main(String []args) { BigInteger bigValue [] = new BigInteger[5]; bigValue[0] = new BigInteger("6464764"); bigValue[1] = new BigInteger("212112221122"); bigValue[2] = new BigInteger("76475"); bigValue[3] = new BigInteger("94874747"); bigValue[4] = new BigInteger("2635474"); for(int i = 0; i< bigValue.length; i++) ... Read More
The 8085AH activates the RD* Signal at 270 nS. This signal moves to OE* pin of 27128 through the octal line driver 74LS241 delayed by 12nS. Hence the signal OE* signal is received by 27128 at the end of time 282 nS. Hence the data can only come out from the pins ranging from D7 to D0 of 27128 by 282 nS + tOE = 282 nS + 75 nS + 357 nS.From the discussion done previously it should be crystal clear that the earliest data output time should be 357 nS, by considering all the three parameters tACC, tCE, and ... Read More
This example demonstrate about How to use vector class in Android listviewStep 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 the name and record number as Edit text, when user clicks on save button it will store the data into ArrayList. Click on ... Read More
Generally, ODBC architecture is of two types single-tier and multi-tier.Single-tier architectureThis is an ODBC architecture which involves single-tier ODBC drivers. In singletier ODBC architecture, the ODBC driver receives ODBC requests/calls from the application and directly interacts with database files. It passes the SQL commands corresponding to the received calls and retrieves the results.Example: Microsoft AccessMultiple-tier architectureThis is an ODBC architecture which involves multiple-tier ODBC drivers. This is a common architecture and is based on client server communication.Client: The application that makes ODBC requests, the driver and the DriverManager together considered as a client.Server: The database and the database software (that ... Read More
It can be checked if a particular LocalDateTime is before the other LocalDateTime in a timeline using the isBefore() method in the LocalDateTime class in Java. This method requires a single parameter i.e. the LocalDateTime object that is to be compared. It returns true if the LocalDateTime object is before the other LocalDateTime object and false otherwise.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Main { public static void main(String[] args) { LocalDateTime ldt1 = LocalDateTime.parse("2019-02-15T11:37:12"); LocalDateTime ldt2 = LocalDateTime.parse("2019-02-18T23:15:30"); System.out.println("The LocalDateTime ldt1 is: ... Read More
This example demonstrate about How to make custom dialog with custom dialog view actions 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 button. When user click on button, it will show custom dialog.Step 3 − Add the following code to src/MainActivity.javapackage com.example.andy.myapplication; import android.os.Build; import android.os.Bundle; import android.support.annotation.RequiresApi; import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatActivity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; public class ... Read More
To calculate a value from multiple columns, use GROUP BY. Following is the syntax −select yourColumnName1, sum(yourColumnName2*yourColumnName3) AS anyAliasName from yourTableName group by yourColumnName1;Let us first create a table −mysql> create table calculateValueDemo -> ( -> Id int, -> ProductPrice int, -> ProductWeight int -> ); Query OK, 0 rows affected (0.56 sec)Following is the query to insert records in the table using insert command −mysql> insert into calculateValueDemo values(100, 35, 5); Query OK, 1 row affected (0.16 sec) mysql> insert into calculateValueDemo values(101, 50, 3); Query OK, 1 row affected (0.16 sec) ... Read More
In order to know the last MySQL error, you can use SHOW command −SHOW ERRORS;Or you can use another syntax −SHOW WARNINGS;Here, we are creating a table that displays an error and then we will find out how to know the last MySQL error. Here, the error occurs because we have intentionally written incorrect create table statement −mysql> create table DemoTable(Id int); ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'create table DemoTable(Id int)' at line 1Following is the query to ... Read More