Skip to main content

Posts

Showing posts from October, 2021

working with auto increment of mysql in JDBC

 working with auto increment of mysql in JDBC For explanation Watch video :: code:: import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.SQLException; public class AutoIncrementEx { private static final String query = "insert into emp2(ename,eadd) values(?,?)"; public static void main(String[] args) { try(Connection con = DriverManager.getConnection("jdbc:mysql:///new","root","root"); PreparedStatement ps = con.prepareStatement(query);){ ps.setString(1, "raja"); ps.setString(2, "nagpur"); int count = ps.executeUpdate(); if(count!=0) { System.out.println("Record Inserted"); }else { System.out.println("Record Not Inserted"); } }catch(SQLException se) { se.printStackTrace(); }catch(Exception e) { e.printStackTrace(); } } }

Weather Observation Station 2 Hackerrank Solution - SQL

 Weather Observation Station 2 Hackerrank Solution - SQL For Explanation watch video::: Code:: select round(sum(LAT_N),2),round(sum(LONG_W),2) from station;

Modified Kaprekar Numbers Hackerrank Solution - java

 Modified Kaprekar Numbers Hackerrank Solution - java For explanation watch video : Code:: import java.io.*; import java.math.*; import java.security.*; import java.text.*; import java.util.*; import java.util.concurrent.*; import java.util.function.*; import java.util.regex.*; import java.util.stream.*; import static java.util.stream.Collectors.joining; import static java.util.stream.Collectors.toList; class Result {     /*      * Complete the 'kaprekarNumbers' function below.      *      * The function accepts following parameters:      *  1. INTEGER p      *  2. INTEGER q      */     public static void kaprekarNumbers(int p, int q) {         ArrayList<Long> al = new ArrayList<>();         for(long i=p;i<=q;i++){             long sq = i*i;             String num = String.valueOf(i);             String s = String.valueOf(sq);             int leftLength = s.length() - num.length();             long leftNum = 0;             if(leftLength == 0){                 lef

Servlet Project : User Management Project

  Servlet Project : User Management Project For Explanation Watch video:: Note :: In this Project you must configure web server (for example tomcat) with eclipse ide Download Bootstrap  from ::         https://getbootstrap.com/docs/4.3/getting-started/download/ Download mysql jar file from :: https://mvnrepository.com/artifact/mysql/mysql-connector-java/8.0.22 adding MySQL Connector/J jar file in eclipse ide for jdbc video :: video link : https://youtu.be/4Fyd-k3eG_I Directory Structure in eclipse web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" id="WebApp_ID" version="4.0">    <welcome-file-list>     <welcome-file>home.html</welcome-file>   </welcome-file-list>   <displa

Servlet Project Book Shop Application in eclipse

 Servlet Project Book Shop Application in eclipse  For explanation watch video::: Note :: In this Project you must configure web server (for example tomcat) with eclipse ide Download Bootstrap  from ::         https://getbootstrap.com/docs/4.3/getting-started/download/ Download mysql jar file from :: https://mvnrepository.com/artifact/mysql/mysql-connector-java/8.0.22 adding MySQL Connector/J jar file in eclipse ide for jdbc video :: video link : https://youtu.be/4Fyd-k3eG_I Directory Structure:: web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" id="WebApp_ID" version="4.0">   <welcome-file-list>     <welcome-file>home.html</welcome-file>   </welcome-file-list>   <display-

equalize the array hackerrank solution in java

 equalize the array hackerrank solution in java for explanation watch video :: code:: import java.io.*; import java.math.*; import java.security.*; import java.text.*; import java.util.*; import java.util.concurrent.*; import java.util.function.*; import java.util.regex.*; import java.util.stream.*; import static java.util.stream.Collectors.joining; import static java.util.stream.Collectors.toList; class Result {     /*      * Complete the 'equalizeArray' function below.      *      * The function is expected to return an INTEGER.      * The function accepts INTEGER_ARRAY arr as parameter.      */     public static int equalizeArray(List<Integer> arr) {                 HashMap<Integer,Integer> hm = new HashMap<>();         for(int i=0;i<arr.size();i++){             hm.put(arr.get(i),hm.getOrDefault(arr.get(i),0)+1);         }                  int max = Integer.MIN_VALUE;         for(Map.Entry<Integer,Integer> e : hm.entrySet()){             int value

Library Fine Hackerrank Solution - java

 Library Fine Hackerrank Solution - java for explanation watch video : code: import  java.io.*; import  java.math.*; import  java.security.*; import  java.text.*; import  java.util.*; import  java.util.concurrent.*; import  java.util.function.*; import  java.util.regex.*; import  java.util.stream.*; import   static  java.util.stream.Collectors.joining; import   static  java.util.stream.Collectors.toList; class  Result {      /*      * Complete the 'libraryFine' function below.      *      * The function is expected to return an INTEGER.      * The function accepts following parameters:      *  1. INTEGER d1      *  2. INTEGER m1      *  3. INTEGER y1      *  4. INTEGER d2      *  5. INTEGER m2      *  6. INTEGER y2      */      public   static   int  libraryFine( int  d1,  int  m1,  int  y1,  int  d2,  int  m2,  int  y2) {          if (y1>y2){              return   10000 ;         } else   if (m1>m2 && y1==y2){              return   500  *(m1-m2);         } else  

Sequence Equation Hackerrank Solution - java

 Sequence Equation Hackerrank Solution - java  for explanation watch video :: code:: import  java.io.*; import  java.math.*; import  java.security.*; import  java.text.*; import  java.util.*; import  java.util.concurrent.*; import  java.util.function.*; import  java.util.regex.*; import  java.util.stream.*; import   static  java.util.stream.Collectors.joining; import   static  java.util.stream.Collectors.toList; class  Result {      /*      * Complete the 'permutationEquation' function below.      *      * The function is expected to return an INTEGER_ARRAY.      * The function accepts INTEGER_ARRAY p as parameter.      */      public   static  List<Integer> permutationEquation(List<Integer> p) {          // p = [4 3 5 1 2]           //     1 2 3 4 5          //1)size of arry          int  n = p.size(); //5          //2)find index of 1 to n in arraylist p         ArrayList<Integer> al1 =  new  ArrayList<>();          for ( int  i= 1 ;i<=n;i++){       

Chocolate Feast Hackerrank Solution - java

Chocolate Feast Hackerrank Solution - java for explanation watch video : code: import java.io.*; import java.math.*; import java.security.*; import java.text.*; import java.util.*; import java.util.concurrent.*; import java.util.function.*; import java.util.regex.*; import java.util.stream.*; import static java.util.stream.Collectors.joining; import static java.util.stream.Collectors.toList; class Result {     /*      * Complete the 'chocolateFeast' function below.      *      * The function is expected to return an INTEGER.      * The function accepts following parameters:      *  1. INTEGER n      *  2. INTEGER c      *  3. INTEGER m      */     public static int chocolateFeast(int n, int c, int m) {         //no of  chocolate          int num = n/c;         int wrapper = num;         if(wrapper<m){             return num;         }else{             while(wrapper>=m){                 num = num + 1;                 wrapper = wrapper - m + 1;             }             ret