Skip to main content

Posts

Image Insertion into MySQL database Using java JDBC

 Image Insertion into MySQL database Using java JDBC  For explanation watch video: Code:: import java.io.FileInputStream; import java.io.InputStream; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.util.Scanner; public class Test { private static final String query = "INSERT INTO IMG_TAB(CNAME,IMAGE) VALUES(?,?)"; public static void main(String[] args)throws Exception{ Scanner scn = new Scanner(System.in); System.out.println("Enter Customer name::"); String cname = scn.next(); System.out.println("Enter the image location: "); String loc = scn.next().replace("?", ""); InputStream is = new FileInputStream(loc); Connection con = DriverManager.getConnection("jdbc:mysql:///new","root","root"); PreparedStatement ps = con.prepareStatement(query); ps.setString(1, cname); ps.setBinaryStream(2, is); int count = ps.exe...

Sherlock and Squares Hackerrank Solution - java

Sherlock and Squares 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 {      public   static   int  squares( int  a,  int  b) {          int  first = ( int )Math.ceil(Math.sqrt(a));          int  last = ( int )Math.floor(Math.sqrt(b));          return  last - first + 1 ;     } } public   class  Solution ...

JDBC Program to access table data from mysql database

 import java.sql.*; class MysqlCon  { public static void main(String[] args)  { try{ Connection con = DriverManager.getConnection("jdbc:mysql:///new","root","root"); Statement st = con.createStatement(); String query = "select * from login"; ResultSet rs = st.executeQuery(query); while(rs.next()){ System.out.println(rs.getString(1)+" "+rs.getString(2)); } con.close(); }catch(SQLException e){ System.out.println("Error"); }catch(Exception e){ } } }

A Very Big Sum Hackerrank Solution - java

 A Very Big Sum 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 'aVeryBigSum' function below.      *      * The function is expected to return a LONG_INTEGER.      * The function accepts LONG_INTEGER_ARRAY ar as parameter.      */     public static long aVeryBigSum(List<Long> ar) {         long sum = 0;         for(int i=0;i<ar.size();i++){             sum = sum + ar.get(i);         }         return sum; ...

Diagonal Difference Hackerrank Solution - java

 Diagonal Difference 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 'diagonalDifference' function below.      *      * The function is expected to return an INTEGER.      * The function accepts 2D_INTEGER_ARRAY arr as parameter.      */      public   static ...

The Blunder Hackerrank Solution - SQL

 The Blunder Hackerrank Solution - SQL For explanation watch video :: Code: select ceil(avg(salary)-avg(replace(salary,'0',''))) from Employees;

java hashset hackerrank solution - java 15

 java hashset hackerrank solution - java 15 for explanation watch video: code: import  java.io.*; import  java.util.*; public   class  Solution {      public   static   void  main(String[] args) {         Scanner scn =  new  Scanner(System.in);          int  t = scn.nextInt();         scn.nextLine();         HashSet<String> hs =  new  HashSet<>();          for ( int  i= 0 ;i<t;i++){             String s = scn.nextLine();             hs.add(s);            ...