How to correctly enclose subquery in MySQL?

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

326 Views

You need to close the subquery in a parenthesis. The syntax is as follows −select if((select count(*) from yourTableName ), 'Yes', 'No') as anyAliasName;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table SelectIfDemo -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Name varchar(10) -> ); Query OK, 0 rows affected (1.03 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into SelectIfDemo(Name) values('John'); Query OK, ... Read More

Java Tuples addAtX() method for Pair class

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

149 Views

The addAtX() method is used to add value at a particular position represented by X here.Let us first see what we need to work with JavaTuples. To work with Pair class in JavaTuples, you need to import the following package −import org.javatuples.Pair;Here we have also used the Triplet class, therefore import the following package −import org.javatuples.Triplet;Note − Steps to download and run JavaTuples program If you are using Eclipse IDE to run Pair Class in JavaTuples, then Right Click Project → Properties → Java Build Path → Add External Jars and upload the downloaded JavaTuples jar file.The following is an ... Read More

Change a MySQL Column datatype from text to timestamp?

Chandu yadav
Updated on 30-Jul-2019 22:30:25

4K+ Views

To change a MySQL column datatype from text to timestamp, you need to use ALTER command.The syntax is as followsALTER TABLE yourTableName MODIFY COLUMN yourColumnName TIMESTAMP;To understand the above syntax, let us create a table.The query to create a table is as followsmysql> create table textTotimestampdemo    - > (    - > Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    - > Source text    - > ); Query OK, 0 rows affected (0.44 sec)Here is the description of table using DESC command.The syntax is as followsDESC yourTableName;The query is as followsmysql> desc textTotimestampdemo;The following is the output+--------+---------+------+-----+---------+----------------+ | ... Read More

Is RowSet Scrollable? Explain with an example?

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

559 Views

A RowSet object is similar to ResultSet, it also stores tabular data, in addition to the features of a ResultSet. A RowSet follows the JavaBeans component model.If you Retrieve a ResultSet object by default the cursor of it moves only in forward direction. i.e. you can retrieve the contents of it from first to last.But, in a scrollable result set, the cursor can scroll forward and backward and you can retrieve data backward too.To make ResultSet object scrollable, you need to create one as shown below −Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);Whereas, a RowSet object is Scrollable by default. Therefore, whenever ... Read More

How to make an HTTP request on iOS App using Swift?

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

984 Views

To make an http request in iOS we’ll make use of DataTask and sessions. We’ll create configuration, sessions, url, request, and dataTask objects. Let’s see the steps that we’ll go through.The HTTP request can be of different types, it depends on what kind of request we want to make to our server. Below are the basic types of requests.“GET”, ”POST”, ”PUT”, ”DELETE” , we can make use of any of these according to our API. The basics remain same for each kind of request, which are shown below. Let’s see these examples with DELETE type of request.First of all we ... Read More

Why people prefer smartphones to laptops nowadays?

Anuradha Nanda
Updated on 30-Jul-2019 22:30:25

206 Views

Before we even start discussing the space and weight constraints of a laptop, many customized/personalized Apps Have Arrived: a touch bar therefore, is a strip of touch-sensitive, context-aware display that replaces the function keys seen in a traditional keyboard.Applications for EventsFor example, in Apple iPhones, the App called ‘Siri’ is also a permanent addition to the touch bar and it is located on the far right-hand side. There are others who state that Windows 10 S is the future of the desktop PC. The Desktop PC which was at one point considered a novelty is now more of an obsolete piece ... Read More

How to score well in college exams?

Anagha N
Updated on 30-Jul-2019 22:30:25

228 Views

Unfortunately, in the Indian education system, we are more concerned about scores on the exams rather than the knowledge. We consider that grades are the only measure of college success. In some sense that is also true because of the competition in the job market.Let us look at some tips to score well in college exams:Since you are out of high school, the first thing you have to learn is taking charge of your life. So step up to bat and take responsibility.Pick up the right courses. Make a balance between the interesting and scoring subjects. But take care that ... Read More

What is a CachedRowSet in JDBC? Explain?

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

3K+ Views

The CachedRowSet is the base implementation of disconnected row sets. It connects to the data source, reads data from it, disconnects with the data source and the processes the retrieved data, reconnects to the data source and writes the modifications.Creating a CachedRowSetYou can create a Cached RowSet object using the createCachedRowSet() method of the RowSetFactory.You can create a RowSetFactory object using the newfactory() method of the RowSetProvider method.Create a CachedRowSet object using the above-mentioned methods as shown below −//Creating the RowSet object RowSetFactory factory = RowSetProvider.newFactory(); CachedRowSet rowSet = factory.createCachedRowSet();Connecting to the data sourceAfter creating a RowSet object you need ... Read More

Java Program to create custom DateTime formatter

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

279 Views

To create custom DateTime formatter, use DateTimeFormatter. Let us first see for Time −DateTimeFormatter dtFormat = new DateTimeFormatterBuilder() .appendValue(ChronoField.HOUR_OF_DAY) .appendLiteral(":") .appendValue(ChronoField.MINUTE_OF_HOUR) .appendLiteral(":") .appendValue(ChronoField.SECOND_OF_MINUTE) .toFormatter();For Date −dtFormat = new DateTimeFormatterBuilder() .appendValue(ChronoField.YEAR) .appendLiteral("/") .appendValue(ChronoField.MONTH_OF_YEAR) .appendLiteral("/") .appendValue(ChronoField.DAY_OF_MONTH) .toFormatter();Exampleimport java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatterBuilder; import java.time.temporal.ChronoField; public class Demo {    public static void main(String[] args) {       DateTimeFormatter dtFormat = new DateTimeFormatterBuilder()       .appendValue(ChronoField.HOUR_OF_DAY)       .appendLiteral(":")       .appendValue(ChronoField.MINUTE_OF_HOUR)       .appendLiteral(":")       .appendValue(ChronoField.SECOND_OF_MINUTE)       .toFormatter();       System.out.println("Time = "+dtFormat.format(LocalDateTime.now()));       dtFormat = new DateTimeFormatterBuilder()     ... Read More

How to start intent service for every 10 sec's in android?

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

1K+ Views

Before getting into example, we should know what Intent service is in android. Intent Service is going to do back ground operation asynchronously. When user call startService() from activity , it doesn't create instance for each request. It going to stop service after done some action in service class or else we need to stop service using stopSelf().This example demonstrate about How to start intent service for every 10 sec’s.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 ... Read More

Advertisements