KeyFactory getAlgorithm Method in Java

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

106 Views

The algorithm name for the KeyFactory can be obtained using the method getAlgorithm() in the class java.security.KeyFactory. This method requires no parameters and it returns the algorithm name for the KeyFactory.A program that demonstrates this is given as follows −Example Live Demoimport java.security.*; import java.util.*; import java.security.spec.*; public class Demo {    public static void main(String[] argv) throws Exception {       try {          KeyFactory kf = KeyFactory.getInstance("RSA");          String algorithm = kf.getAlgorithm();          System.out.println("The Algortihm is: " + algorithm);       } catch (NoSuchAlgorithmException e) { ... Read More

Print Hollow Pyramid and Diamond Pattern in C

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

3K+ Views

Here we will see how to generate hollow pyramid and diamond patterns using C. We can generate solid Pyramid patterns very easily. To make it hollow, we have to add some few tricks.Hollow PyramidFor the pyramid at the first line it will print one star, and at the last line it will print n number of stars. For other lines it will print exactly two stars at the start and end of the line, and there will be some blank spaces between these two starts.Example Code#include int main() {    int n, i, j;    printf("Enter number of lines: ... Read More

Set MySQL Database to Use MyISAM by Default

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

623 Views

To set the default storage engine, use the following syntax −set @@default_storage_engine = ’yourEngineType’;Now implement the above syntax to set the default engine to MyISAM. The query is as follows −mysql> set @@default_storage_engine = 'MyISAM'; Query OK, 0 rows affected (0.05 sec)Now you can check the default engine type with the help of SELECT statement. The query is as follows −mysql> select @@default_storage_engine;The following is the output displaying the engine as MyISAM −+--------------------------+ | @@default_storage_engine | +--------------------------+ | MyISAM | +--------------------------+ 1 ... Read More

Standard Attributes for Custom Tags in JSP Page

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

79 Views

Consider including the following properties for an attribute −S.No.Property & Purpose1nameThe name element defines the name of an attribute. Each attribute name must be unique for a particular tag.2requiredThis specifies if this attribute is required or is an optional one. It would be false for optional.3rtexprvalueDeclares if a runtime expression value for a tag attribute is valid4typeDefines the Java class-type of this attribute. By default, it is assumed as String5descriptionInformational description can be provided.6fragmentDeclares if this attribute value should be treated as a JspFragment.Following is the example to specify properties related to an attribute −.....           ... Read More

Check Index of Substring in JSP

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

528 Views

The fn:indexOf() function returns the index within a string of a specified substring.SyntaxThe fn:indexOf() function has the following syntax −int indexOf(java.lang.String, java.lang.String)ExampleFollowing is the example to explain the functionality of the fn:indexOf() function − Using JSTL Functions Index (1) : ${fn:indexOf(string1, "first")} Index (2) : ${fn:indexOf(string2, "second")} You will receive the following result −Index (1) : 8 Index (2) : 13

MonthDay isSupported Method in Java

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

118 Views

It can be checked if a ChronoField is supported by the MonthDay class or not by using the isSupported() method in the MonthDay class in Java. This method requires a single parameter i.e. the ChronoField to check. It returns true if the ChronoField is supported by the MonthDay class and false otherwise.A program that demonstrates this is given as followsExample Live Demoimport java.time.*; import java.time.temporal.*; public class Demo {    public static void main(String[] args) {       MonthDay md = MonthDay.now();       System.out.println("The MonthDay is: " + md);       boolean flag = md.isSupported(ChronoField.MONTH_OF_YEAR);     ... Read More

Duration Today's Method in Java

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

124 Views

The value of a particular duration in the number of days can be obtained using the toDays() method in Java. This method requires no parameters and it returns the duration in the number of days.A program that demonstrates this is given as follows −Example Live Demoimport java.time.Duration; public class Demo {    public static void main(String[] args) {       Duration d = Duration.ofHours(48);       System.out.println("The duration is: " + d);       System.out.println("The number of days in the duration is: " + d.toDays());    } }OutputThe duration is: PT48H The number of days in the duration ... Read More

Stop MongoDB in a Single Command

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

631 Views

In order to stop MongoDB in a single command, use the following syntax −mongo --eval "db.getSiblingDB('admin').shutdownServer()"Let us implement the above syntax in order to stop MongoDB in one command.First, use the shortcut key −Ctrl + C;The query is as follows −C:\Program Files\MongoDB\Server\4.0\bin>mongo --eval "db.getSiblingDB('admin').shutdownServer()"The following is the output − displaying the shutdown of the MongoDB server −MongoDB shell version v4.0.5 connecting to: mongodb://127.0.0.1:27017/?gssapiServiceName=mongodb Implicit session: session { "id" : UUID("c0337c02-7ee2-45d9-9349-b22d6b1ffe85") } MongoDB server version: 4.0.5 server should be down... 2019-03-14T21:56:10.327+0530 I NETWORK [js] trying reconnect to 127.0.0.1:27017 failed 2019-03-14T21:56:11.331+0530 I NETWORK [js] reconnect 127.0.0.1:27017 failed failed 2019-03-14T21:56:11.333+0530 I QUERY [js] ... Read More

Reserving MySQL Auto-Incremented IDs

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

383 Views

To reserve MySQL auto-incremented IDs, the syntax is as follows −START TRANSACTION; insert into yourTableName values(), (), (), (); ROLLBACK; SELECT LAST_INSERT_ID() INTO @anyVariableName;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table reservingAutoIncrementDemo    -> (    -> UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY    -> ); Query OK, 0 rows affected (0.45 sec)Insert some records in the table using insert command. The query is as follows −mysql> START TRANSACTION; Query OK, 0 rows affected (0.00 sec) mysql> insert into reservingAutoIncrementDemo values(), (), (), (); Query ... Read More

Set Auto Increment Later in MySQL

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

150 Views

Yes, you can set Auto Increment later with ALTER table. Let us first create a table. Here, as you can see, we haven’t set Auto Increment −mysql> create table forgetToSetAutoIncrementDemo    -> (    -> StudentId int,    -> StudentName varchar(30)    -> ); Query OK, 0 rows affected (1.17 sec)Now check the table description, there is no auto_increment column −mysql> desc forgetToSetAutoIncrementDemo;This will produce the following output −+-------------+-------------+------+-----+---------+-------+ | Field       | Type        | Null | Key | Default | Extra | +-------------+-------------+------+-----+---------+-------+ | StudentId   | int(11)     | YES  |   ... Read More

Advertisements