Use Real Data Type in Android SQLite

Smita Kapse
Updated on 30-Jul-2019 22:30:25

402 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 use real data type in Android sqliteStep 1 −Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to ... Read More

Write If-Else Statement in a JSP Page

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

16K+ Views

The if...else block starts out as an ordinary Scriptlet, but the Scriptlet is closed at each line with HTML text included between the Scriptlet tags.Example Live Demo           IF...ELSE Example                         Today is weekend                 Today is not weekend           The above code will generate the following result −Today is not weekend

Retrieve Time from a Table in JDBC

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

447 Views

The ResultSet interface provides a method named getTime() this method accepts an integer parameter representing the index of the column, (or, a String parameter representing the name of the column) from which you need to retrieve the time value. To retrieve time value from a table −Register the driver class using the registerDriver() method of the DriverManager class. Pass the driver class name to it, as parameter.Connect to the database using the getConnection() method of the DriverManager class. Passing URL (String), username (String), password (String) as parameters to it.Create a Statement object using the createStatement() method of the Connection interface.Execute ... Read More

Create Ennead Tuple from a List Collection in Java

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

162 Views

To create Ennead Tuple from a List collection, use the fromCollection() method. Firstly, create a List like this and then create an Ennead Tuple using ListList myList = new ArrayList(); myList.add("Accessories"); myList.add("Shirt"); myList.add("Trousers"); myList.add("Furniture"); myList.add("Smart Wearable Tech"); myList.add("Smart Home Automation"); myList.add("Books"); myList.add("Stationery"); myList.add("Instrument");Let us first see what we need to work with JavaTuples. To work with Ennead class in JavaTuples, you need to import the following packageimport org.javatuples.Ennead;Note Download JavaTuples Jar library to run JavaTuples program. If you are using Eclipse IDE, then Right Click Project -> Properties -> Java Build Path -> Add External Jars and upload the downloaded ... Read More

Period isZero Method in Java

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

169 Views

It can be checked if the days, months and years in the Period are zero or not using the isZero() method in the Period class in Java. This method requires no parameters. Also, it returns true if the days, months and years in the Period are zero and false otherwise.A program that demonstrates this is given as followsExample Live Demoimport java.time.Period; public class Demo {    public static void main(String[] args) {       String period = "P0Y0M0D";       Period p = Period.parse(period);       System.out.println("The Period is: " + p);       System.out.println("The days, months ... Read More

MySQL Temporary Variable Assignment

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

4K+ Views

You can use SET command for temporary variable assignment.The syntax is as followsSET @anyVariableName=(SELECT yourColumnName FROM yourTableName WHERE yourCondition);To understand the above syntax, let us create a table. The query to create a table is as followsmysql> create table tempVariableAssignment    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> Name varchar(20),    -> Age int    -> ); Query OK, 0 rows affected (0.59 sec)Now insert some records in the table using insert commandmysql> insert into tempVariableAssignment(Name, Age) values('John', 25); Query OK, 1 row affected (0.14 sec) mysql> insert into tempVariableAssignment(Name, Age) values('Carol', 26); Query ... Read More

Best Way to Store Weekly Event in MySQL

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

274 Views

Let us see the best way to store weekly events in MySQL. For that, first create a new table and include fields for every day as well.mysql> create table WeeklyEventDemo -> ( -> ID int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> EventName varchar(20), -> Monday tinyint(1), -> Tuesday tinyint(1), -> Wednesday tinyint(1), -> Thursday tinyint(1), -> Friday tinyint(1), -> Saturday tinyint(1), -> Sunday tinyint(1), -> StartDate date, ... Read More

Fetch Key from a Key-Value Tuple in Java

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

187 Views

To fetch the key from a KeyValue tuple in Java, use the getKey() method. Let us first see what we need to work with JavaTuples. To work with KeyValue class in JavaTuples, you need to import the following package:import org.javatuples.KeyValue;Note: Download JavaTuples Jar library to run JavaTuples program. If you are using Eclipse IDE, then Right Click Project → Properties → Java Build Path → Add External Jars and upload the downloaded JavaTuples jar file. Refer the below guide for all the steps to run JavaTuples:Steps: How to run JavaTuples program in EclipseThe following is an example to fetch the ... Read More

Prevent MongoDB from Returning Object ID while Finding Document

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

639 Views

To prevent MongoDB from returning the Object ID while finding a document, you need to set _id to 0. Let us first create a collection with documents> db.preventObjectIdDemo.insertOne( ...    { ... ...       "StudentName" : "Chris", ...       "StudentDetails" : [ ...          { ...             "StudentTotalScore" : 540, ...             "StudentCountryName" : "US" ...          }, ...          { ...             "StudentTotalScore" : 489, ...           ... Read More

Get Previous and Next Index Using ListIterator in Java

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

218 Views

To get the exact evaluation of the previous and next index, you need use the next() method of the Iterator. This will eventually help you in gaining more understanding about Iterators. Let us first create an ArrayList and add some elements −ArrayList arrList = new ArrayList (); arrList.add(100); arrList.add(200); arrList.add(300); arrList.add(400); arrList.add(500); arrList.add(600); arrList.add(700); arrList.add(800); arrList.add(900); arrList.add(1000);Now, create a ListIterator −ListIteratoriterator = arrList.listIterator();Get the previous and next index now −iterator.previousIndex(); iterator.nextIndex();Example Live Demoimport java.util.ArrayList; import java.util.ListIterator; public class Demo {    public static void main(String[] args) {       ArrayListarrList = new ArrayList();       arrList.add(100);   ... Read More

Advertisements