Insert Own Values into Auto Increment Column in MySQL

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

799 Views

You can achieve this with the help of INSERT statement i.e, you can simply insert it like a normal insert. The syntax is as follows −INSERT INTO yourTableName (yourIdColumnName, yourColumnName) values(value1, 'value2'); Let us first create a table: mysql> create table InsertValueInAutoIncrement -> ( -> UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> UserName varchar(20) -> ); Query OK, 0 rows affected (0.59 sec)Now you can insert some records in the table using insert command. Here, we are also inserting our own values for the auto_increment field UserId. ... Read More

What are Filters in JSP

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

232 Views

Servlet and JSP Filters are Java classes that can be used in Servlet and JSP Programming for the following purposes To intercept requests from a client before they access a resource at the back end.To manipulate responses from the server before they are sent back to the client.There are various types of filters suggested by the specifications −Authentication FiltersData compression FiltersEncryption FiltersFilters that trigger resource access eventsImage Conversion FiltersLogging and Auditing FiltersMIME-TYPE Chain FiltersTokenizing FiltersXSL/T Filters That Transform XML ContentFilters are deployed in the deployment descriptor file web.xml and then map to either servlet or JSP names or URL patterns in ... Read More

Get Current State of Activity in Android

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

815 Views

This example demonstrates How to get current state of activity in android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.     In the above code, we have taken text view to show activity state.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.app.ActivityManager; import android.app.admin.DevicePolicyManager; import android.content.ComponentName; import android.content.Context; import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; import android.os.Build; import android.os.Bundle; import android.support.annotation.RequiresApi; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.TextView; public class MainActivity extends AppCompatActivity { ... Read More

IntStream flatMap Method in Java

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

845 Views

The flatMap() method of the IntStream class returns a stream consisting of the results of replacing each element of this stream with the contents of a mapped stream produced by applying the provided mapping function to each element.The syntax is as followsIntStream flatMap(IntFunction

Duration plusHours Method in Java

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

104 Views

An immutable copy of a duration where some hours are added to it can be obtained using the plusHours() method in the Duration class in Java. This method requires a single parameter i.e. the number of hours to be added and it returns the duration with the added hours.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(1);       System.out.println("The duration is: " + d);       System.out.println("A copy with 2 hours added to the duration is: ... Read More

The Build Method in Java LongStream Builder

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

164 Views

The build() method of the LongStream.Builder class builds the stream and returns the built stream. The following is the syntax:LongStream build()Import the following package for the LongStream.Builder class in Java:import java.util.stream.LongStream;Declare a LongStream.Builder and add elements:LongStream.Builder builder = LongStream.builder(); builder.add(24000L); builder.add(47470L); builder.add(12999L);Now, use the build() method to build the stream:builder.build()The following is an example displaying how to implement build() method of LongStream.Builder in Java:Example Live Demoimport java.util.stream.LongStream; public class Demo {    public static void main(String[] args) {       LongStream.Builder builder = LongStream.builder();       builder.add(24000L);       builder.add(47470L);       builder.add(12999L);       ... Read More

Read and Write Structure to a File Using C

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

12K+ Views

fwrite() and fread() is used to write to a file in C.fwrite() syntaxfwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream)whereptr - A pointer to array of elements to be writtensize - Size in bytes of each element to be writtennmemb - Number of elements, each one with a size of bytesstream – A pointer to a FILE object that specifies an output streamfread() syntaxfread(void *ptr, size_t size, size_t nmemb, FILE *stream)whereptr - A pointer to a block of memory with a minimum size of size*nmemb bytes.size - Size in bytes of each element to be read.nmemb - Number of ... Read More

View Auto Increment Value for a Table in MySQL

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

160 Views

To view the auto_increment value for a table, you can use INFORMATION_SCHEMA.TABLES.Let us first create a table −mysql> create table viewtheauto_incrementValueForATableDemo    -> (    -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> StudentName varchar(20)    -> ); Query OK, 0 rows affected (0.84 sec)Following is the query to insert some records in the table using insert command −mysql> insert into viewtheauto_incrementValueForATableDemo(StudentName) values('Ramit'); Query OK, 1 row affected (0.23 sec) mysql> insert into viewtheauto_incrementValueForATableDemo(StudentName) values('Bob'); Query OK, 1 row affected (0.14 sec) mysql> insert into viewtheauto_incrementValueForATableDemo(StudentName) values('Chris'); Query OK, 1 row affected (0.15 sec) mysql> ... Read More

Convert Instant to LocalDateTime in Java

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

575 Views

Let’s say you need to convert Instant to LocalDateTime with IST with timezone:Create an Instant:Instant instant = new Date().toInstant();Now, convert Instant to LocalDateTime:LocalDateTime date = LocalDateTime.ofInstant(instant, ZoneId.of(ZoneId.SHORT_IDS.get("IST")));Exampleimport java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; import java.util.Date; public class Demo {    public static void main(String[] args) {       Instant instant = new Date().toInstant();       LocalDateTime date = LocalDateTime.ofInstant(instant, ZoneId.of(ZoneId.SHORT_IDS.get("IST")));       System.out.println("Date (IST) = " + date);       date = LocalDateTime.ofInstant(instant, ZoneId.of(ZoneId.SHORT_IDS.get("PST")));       System.out.println("Date (PST) = " + date);       date = LocalDateTime.ofInstant(instant, ZoneId.of(ZoneId.SHORT_IDS.get("EST")));       System.out.println("Date (EST) = " ... Read More

Change File Extension in Text Column in MySQL

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

456 Views

To change the file extension in the text column, you can use UPDATE command along with REPLACE() function. Let’s say we have some columns with extensions and we need to replace all of them. For that, let us first create a table with the extension columns set as text type:mysql create table DemoTable (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    ProgramExtension1 text,    ProgramExtension2 text,    ImageExtension text ); Query OK, 0 rows affected (0.52 sec)Following is the query to insert records in the table using insert command:mysql> insert into DemoTable(ProgramExtension1, ProgramExtension2, ImageExtension)values('.java', '.c', '.jpeg'); Query OK, ... Read More

Advertisements