devxlogo

The Latest

Using LOCK_TIMEOUT in SQL

LOCK_TIMEOUT?specifies the number of milliseconds a statement should wait for a lock to be released, for example: SET LOCK_TIMEOUT 1000 –Wait one second Related Posts Oracle Buys StackEngine, Builds Cloud

How to Change the Storage Engine in MySQL

Every table in MySQL will have a storage engine that offers certain capabilities. Some storage engines offer performance, some of them transaction support, and so on. By default, all tables

Get the Class-Level Annotation

Via Java Reflection API, we can obtain all the annotations of a class as follows: Class clazz = Foo.class;Annotation[] clazzAnnotations = clazz.getAnnotations(); Related Posts How to Create a Custom jQuery

Using NUMERIC_ROUNDABORT in T-SQL

NUMERIC_ROUNDABORT?specifies the level of error reporting that has been generated when an expression being rounded has caused loss of precision. SET NUMERIC_ROUNDABORT ON Related Posts More Unbeatable Black Friday Tech

Using SoapHexBinary Class for Byte and String Conversions

See below for a code sample of how to perform byte and string conversions: using System.Runtime.Remoting.Metadata.W3cXsd2001;public static byte[] GetStringToBytes(string stringValue){ SoapHexBinary result = SoapHexBinary.Parse(stringValue); return result.Value;}public static string GetBytesToString(byte[] byteArray){

Understanding What Grants a User Has in MySQL

MySQL allows various permissions to be set for users during (or after) creation. The following command comes handy to understand what GRANTS a user has. Command: SHOW GRANTS FOR user;

Get the UTC Machine Time in Java

Beginning with JDK 8, the machine UTC timestamp with nanoseconds precision can be obtained via the java.time.Instant class as below: // e.g., 2019-02-26T15:28:21.051163100ZInstant now = Instant.now(); Related Posts Perforce Powers

Reseed All Autonumber Fields in All Tables

Reseed all Autonumber fields in all tables with the following query: EXEC sp_MSForEachTable ‘ IF OBJECTPROPERTY(object_id(”?”), ”TableHasIdentity”) = 1 DBCC CHECKIDENT (”?”, RESEED, 0) Related Posts More Details about the

Creating an Immutable List via JDK 9

Starting with JDK 9, we can create an immutable list via the suite of List#of(…) methods. For example, an immutable list of 3 elements can be created as follows: import java.util.List;…List

Repeating Text n Times via Stream.generate()

There are several approaches for repeating a string n times. In functional-style, we can rely on Stream.generate(), as in the following example: String result = Stream.generate(() – TEXT) .limit(5) .collect((joining()));

How to Use the Show ProcessList in MySQL

This command is similar to that of an operating system command that shows all the processes. In MySQL, this command, when executed, lists all of the processes that hold a

Comparing Two Integers

Before Java 7, this task required a comparator and the compareTo() method. But, beginning with Java 7, is advisable to rely on Integer.compare(), which is not exposed to overflow risks

Get the Last Day of the Current Month

To get the last day of the current month, do the following: SELECT CONVERT(VARCHAR(25), DATEADD(DAY, -(DAY(GETDATE())), DATEADD(MONTH, 1, GETDATE())), 105) LastDay Related Posts BYD unveils new plug-in hybrids in MilanHow

Getting to Know the Available Drives in the System

Finding all of the available drives in the system is often useful. The following code snippet brings up a list of the available drives: */import java.io.File;public class SystemDrives{ public static

Enabling Hibernate Statistics

In order to obtain statistics regarding SQL queries executed via Hibernate, we need to set hibernate.generate_statistics=true. In Spring, we need to add in application.properties the following setting: spring.jpa.properties.hibernate.generate_statistics=true Related Posts

Get Current Precision Level Used by Numbers in SQL Server

You can get the current precision by executing the following command: SELECT @@MAX_PRECISION AS ‘MAX_PRECISION’ Related Posts Significant boost for Social Security cheques announcedUsing SendKeys in C#this is test headerCybersecurity

Understanding the Collections.unmodifiableCollection

Collection has an unmodifiableCollection method that returns a collection object that cannot be modified. It means that you cannot add or remove any element from the collection. import java.util.*;public class UnmodifiableCollection{

Apply String Indentation

Beginning with JDK 12, we can indent strings via String.indent(int n), in which n is the number of spaces.Example : indent text “abc” with 10 spaces: “abs”.indent(10); Related Posts How AI

Rebuild All Database Indexes

You can rebuild all indexes present in your database with the following query: EXEC sp_MSforeachtable @command1=”print ‘?’ DBCC DBREINDEX (‘?’, ‘ ‘, 80)” GO EXEC sp_updatestats GO Related Posts Arizona

Get Current Language of SQL Server

You can get the current language of SQL Server with the following command: SELECT @@LANGUAGE AS Current_Language; Related Posts Tower Semiconductor Submits New Wafer Facility ProposalIBM Unveils IoT for Automotive

Expore the TemporalAdjusters Class in Java

TemporalAdjusters is a class in Java that is oriented towards bettering the options of Calendar. You can easily compute the dates of firstDayOfNextMonth, lastDayOfMonth, next Wednesday, etc. TemporalAdjusters have many more methods

Return a Boolean if the Optional Is Empty

Beginning with JDK 11, we can return a boolean if the Optional is empty via Optional#isEmpty(): public boolean bookIsEmpty(long id) { Optional book = // code that fetches the book

Recompile a Stored Procedure

You can recompile certain stored procedures with the following command: EXEC sp_recompile ‘Procedure_Name’; GO Related Posts Microsoft Launches Visual Studio 2015, .NET 4.6SUSE Releases OpenStack Cloud 5Conditionally Load CSS Files

Define an URL to a Local File

If we want to define a valid URL instance for a file we need to add the “file” protocol as in the following example: URL url = new URL(“file:///C:/photos/me.png”); Related

Regex Has a Presence in Java as Well

See how to use this form of Regex below to identify whether or not a string has only alphabets present. public class RegexHasOnlyAlphabets{ public static void main(String args[]) { RegexHasOnlyAlphabets

RESEED Identity Columns of All Tables

You can RESEED?Identity Columns of all tables by using sp_MSForEachTable?to loop through all the tables and executing the DBCC CHECKIDENT?command if the specific table has an identity column: EXEC sp_MSForEachTable

Operations on Dates and Times

See how to add or subtract days, months or years with these operations. LocalDate tomorrow = LocalDate.now().plusDays(3);LocalDateTime anHourFromNow = LocalDateTime.now().plusHours(10);Long daysBetween = java.time.temporal.ChronoUnit.DAYS.between(LocalDate.now(), LocalDate.now().plusDays(2));Duration duration = Duration.between(Instant.now(), ZonedDateTime.parse(“2018-08-30T09:00:00+01:00[Europe/Stockholm]”)); Related Posts

Working with the IIF Statement in T-SQL

You can use the IIF statement to check quickly for conditions. For example: DECLARE @Spy varchar(20) = ’07’ SELECT IIF(@Spy = ‘007’, ‘Bond, James Bond’, ‘Ernst Stavro Blofeld’) If the