Retrieve Date from a Table in JDBC

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

4K+ Views

The ResultSet interface provides a method named getDate() 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 date value. To retrieve date 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

ArrayBlockingQueue Size Method in Java

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

177 Views

To get the number of elements in the queue, use the size() method of the ArrayBlockingQueue class.The syntax is as followsint size()To work with ArrayBlockingQueue class, you need to import the following packageimport java.util.concurrent.ArrayBlockingQueue;The following is an example to implement size() method of Java ArrayBlockingQueue classExample Live Demoimport java.util.concurrent.ArrayBlockingQueue; public class Demo { public static void main(String[] args) throws InterruptedException { ArrayBlockingQueue q = new ArrayBlockingQueue(10); q.add(200); q.add(310); q.add(400); ... Read More

Fetch Value from a Label-Value Tuple in Java

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

171 Views

To fetch the value from a LabelValue class in Java, you need to use the getValue() method. To get the key, use the getLabel() method. Let us first see what we need to work with JavaTuples. To work with LabelValue class in JavaTuples, you need to import the following package −import org.javatuples.LabelValue;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 ... Read More

LocalTime plusHours Method in Java

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

89 Views

An immutable copy of a LocalTime object where some hours are added to it can be obtained using the plusHours() method in the LocalTime class in Java. This method requires a single parameter i.e. the number of hours to be added and it returns the LocalTime object with the added hours.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Demo {    public static void main(String[] args) {       LocalTime lt = LocalTime.now();       System.out.println("The current LocalTime is: " + lt);       System.out.println("The LocalTime with 3 hours added is: ... Read More

Write Procedure to Insert Data in Table in phpMyAdmin

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

511 Views

Let us first create a new table and understand the concept in continuationmysql> create table StoredProcedureInsertDemo    -> (    -> UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> UserName varchar(20),    -> UserAge int    -> ); Query OK, 0 rows affected (0.63 sec)Here is the query to create a stored procedure to insert data in to the tablemysql> DELIMITER // mysql> create procedure procedure_InsertIntoTable(IN FirstName VARCHAR(100), IN Age INT)    -> BEGIN    -> insert into StoredProcedureInsertDemo(UserName, UserAge) values (FirstName, Age);    -> END    -> // Query OK, 0 rows affected (0.34 sec) mysql> DELIMITER ;Call ... Read More

Remove Method of AbstractList Class in Java

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

335 Views

Remove an element at a specified position from the list using the remove() method. The position is to be set as index parameter in the method itself. It returns the element which is removed.The syntax is as follows:public E remove(int index)Here, index is the index from where you want to delete the element.To work with the AbstractList class, import the following package:import java.util.AbstractList;The following is an example to implement remove() method of the AbstractlList class in Java:Example Live Demoimport java.util.ArrayList; import java.util.AbstractList; public class Demo {    public static void main(String[] args) {       AbstractList myList = new ArrayList(); ... Read More

Register Custom Intent Filter to Broadcast Receiver in Android

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

3K+ Views

Before getting into the example, we should know what is intent filter in android. An intent filter is an instance of the IntentFilter class. Intent filters are helpful while using implicit intents, It is not going to handle in java code, we have to set it up in AndroidManifest.xml. Android must know what kind of intent it is launching so intent filters give the information to android about intent and actions.Before launching intent, android going to test action test, category test and data test. This example demonstrate about how to use custom intent filters to a broadcast receiver in android.Step ... Read More

Update Only Specific Fields in MongoDB

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

840 Views

To update only specific field, you can use $set operator. Let us first create a collection with documents>db.updateOnlySpecificFieldDemo.insertOne({"EmployeeName":"John", "EmployeeCountryName":"UK"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c9ea849d628fa4220163b72") } >db.updateOnlySpecificFieldDemo.insertOne({"EmployeeName":"Larry", "EmployeeCountryName":"US"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c9ea853d628fa4220163b73") } >db.updateOnlySpecificFieldDemo.insertOne({"EmployeeName":"David", "EmployeeCountryName":"AUS"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c9ea85bd628fa4220163b74") }Following is the query to display all documents from a collection with the help of find() method> db.updateOnlySpecificFieldDemo.find().pretty();This will produce the following output{    "_id" : ObjectId("5c9ea849d628fa4220163b72"),    "EmployeeName" : "John",    "EmployeeCountryName" : "UK" } {    "_id" : ObjectId("5c9ea853d628fa4220163b73"),    "EmployeeName" : "Larry",    "EmployeeCountryName" : ... Read More

Check Frequency of an Element in Java with Collections Frequency

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

263 Views

Create a List in Java −List< String >list = Arrays.asList("P", "Q", "R", "P", "T", "P", "U", "V", "W", "X", "W" );Now, let’s say you want to get the frequency of element P. For that, use the Collections.frequency() method −Collections.frequency(list, "P");A shown above, we can find the occurrence of any letter as well −Collections.frequency(list, "T");Example Live Demoimport java.util.Arrays; import java.util.Collections; import java.util.List; public class Demo {    public static void main(String[] args) {       Listlist = Arrays.asList("P", "Q", "R", "P", "T", "P", "U", "V", "W", "X", "W" );       int checkOccurrence = Collections.frequency(list, "P");       System.out.println("Occurrence ... Read More

Do Double Equal Sign Exist in MySQL

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

3K+ Views

There is no double equal sign concept. It can be used to compare two values. If you use double equal sign(==) in MySQL, you will get an error message.Let us verify the concept is true or not. Declare a variable −mysql> set @Number=10; Query OK, 0 rows affected (0.00 sec)Now, compare the above variable value with 10. If both the values are same then the result will be 1 otherwise 0.Using double equal sign −mysql> select 10==@Number;This will produce the following output i.e. an error −ERROR 1064 (42000): You have an error in your SQL syntax; check the manual ... Read More

Advertisements