Samual Sam has Published 2492 Articles

How to set the data source in a JSP?

Samual Sam

Samual Sam

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

432 Views

The tag sets the data source configuration variable or saves the data-source information in a scoped variable that can be used as input to the other JSTL database actions.AttributeThe tag has the following attributes −AttributeDescriptionRequiredDefaultdriverName of the JDBC driver class to be registeredNoNoneurlJDBC URL for the database connectionNoNoneuserDatabase ... Read More

What is a page directive in JSP?

Samual Sam

Samual Sam

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

171 Views

The page directive is used to provide instructions to the container. These instructions pertain to the current JSP page. You may code page directives anywhere in your JSP page. By convention, page directives are coded at the top of the JSP page.Following is the basic syntax of the page directive ... Read More

How to generate large random numbers in Java?

Samual Sam

Samual Sam

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

461 Views

For large random numbers, use BigInteger type in Java. At first, create a Random object −Random randNum = new Random();Now, declare a byte array and generate random bytes −byte[] b = new byte[max]; randNum.nextBytes(b);Now, generate a large random number with BigInteger type −BigInteger bigInt = new BigInteger(b);Example Live Demoimport java.math.BigInteger; import ... Read More

How to execute SQL update query in a JSP?

Samual Sam

Samual Sam

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

394 Views

The tag executes an SQL statement that does not return data; for example, SQL INSERT, UPDATE, or DELETE statements.AttributeThe tag has the following attributes −AttributeDescriptionRequiredDefaultsqlSQL command to execute (should not return a ResultSet)NoBodydataSourceDatabase connection to use (overrides the default)NoDefault databasevarName of the variable to store the count of ... Read More

Query with values prepended by ampersand works in Oracle but not in MySQL?

Samual Sam

Samual Sam

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

94 Views

Ampersands work in Oracle. To work it in MySQL, use @ as shown in the following syntax −SET @yourVariableName1 = yourValue, @yourVariableName2 = yourValue, @yourVariableName3 =yourValue, .........N; insert into yourTableName values(@yourVariableName1, @yourVariableName2, @yourVariableName3, ........N);To understand the above syntax, let us create a table. The query to create a table is ... Read More

How can I generate random booleans in Java?

Samual Sam

Samual Sam

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

244 Views

To generate random booleans like TRUE or FALSE, at first create a new Random object −Random randNum = new Random();Now, loop through the count of booleans you want and generate random booleans with nextBooleans() method −for (int i = 1; i

ConcurrentSkipListSet in Java

Samual Sam

Samual Sam

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

164 Views

The ConcurrentSkipListSet has elements that are sorted by default. Also, its implementation is based on the ConcurrentSkipListMap. The ConcurrentSkipListSet class also implements the Collection interface as well as the AbstractSet class. It is a part of the Java Collection Framework.A program that demonstrates this is given as follows −Example Live Demoimport ... Read More

Java Signature getProvider() method

Samual Sam

Samual Sam

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

128 Views

The provider for the signature object can be obtained using the method getProvider() in the class java.security.Signature. This method requires no parameters and it returns the provider for the signature object.A program that demonstrates this is given as follows −Example Live Demoimport java.security.*; import java.util.*; public class Demo {    public ... Read More

What is a buffer attribute in JSP?

Samual Sam

Samual Sam

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

739 Views

The buffer attribute specifies the buffering characteristics for the server output response object.You may code a value of "none" to specify no buffering so that the servlet output is immediately directed to the response object or you may code a maximum buffer size in kilobytes, which directs the servlet to ... Read More

Sorting a vector in descending order in C++

Samual Sam

Samual Sam

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

17K+ Views

Sorting a vector in C++ can be done by using std::sort(). It is defined in header. To get a stable sort std::stable_sort is used. It is exactly like sort() but maintain the relative order of equal elements. Quicksort(), mergesort() can also be used, as per requirement.Sorting a vector in descending ... Read More

Advertisements