Retrieve Time from a Table in JDBC

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

424 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

135 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

155 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

3K+ 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

258 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

167 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

601 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

190 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

Auto Increment Value of Tables to Lower Value in MySQL

Krantik Chavan
Updated on 30-Jul-2019 22:30:25

861 Views

If you’re using InnoDB engine, then you cannot set auto_increment value of tables to lower value. You need to change your engine from InnoDB to MyISAM.Note: The engine MyISAM allows you to set lower value. Here, we are using the same.According to the official documents:You cannot reset the counter to a value less than or equal to any that have already been used. For MyISAM, if the value is less than or equal to the maximum value currently in the AUTO_INCREMENT column, the value is reset to the current maximum plus one. For InnoDB, if the value is less than ... Read More

8086 Program to Multiply Two 8-Bit Numbers

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

12K+ Views

In this program we will see how to multiply two 8-bit numbers.Problem StatementWrite 8086 Assembly language program to multiply two 8-bit numbers stored in memory address offset 500 and 501.DiscussiontIn 8086 there is MUL instruction. So the task is too simple. Here we are taking the numbers from memory and after that performing the multiplication operation. As 8-bit numbers are taken, after multiplication AX (16-bit) will store the result.InputAddressData……5009950125…… Flow Diagram Program OutputAddressData……6001D60116……

Advertisements