Skip to main content

Posts

Weather Observation Station 19 Hackerrank Solution - SQL

  Weather Observation Station 19 Hackerrank Solution - SQL  for explanation watch video :: Code:: select round(sqrt(     power(max(lat_n)-min(lat_N),2)+     power(max(long_w)-min(long_w),2) ),4) from station;

Weather Observation Station 15 Hackerrank Solution - SQL

 Weather Observation Station 15 Hackerrank Solution - SQL For explanation watch video :: Code:: select round(long_w,4) from station where lat_n = (select max(lat_n) from station where lat_n<137.2345);

Weather Observation Station 14 Hackerrank Solution - SQL

Weather Observation Station 14 Hackerrank Solution - SQL For explanation watch video :: Code:: select round(max(LAT_N),4) from station where LAT_N < 137.2345;

Transaction Management in JDBC | JDBC Tutorial

  Transaction Management in JDBC For explanation watch video :: Code:: import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Statement; import java.util.Scanner; public class OracleConn { public static void main(String[] args) { String url = "jdbc:oracle:thin:@localhost:1521:orcl"; String uname = "system"; String pwd = "tiger"; // take source account number and dest acc number from user Scanner scn = new Scanner(System.in); System.out.println("Enter source acc no: "); long srcAcNo = scn.nextLong(); System.out.println("Enter dest acc no: "); long destAcNo = scn.nextLong(); // take the amt to transfer System.out.println("Enter amt to transfer: "); long amt = scn.nextLong(); try (Connection con = DriverManager.getConnection(url, uname, pwd);  Statement st = con.createStatement();) { // Begin Tx if (con != null) con.set...

Batch Processing in JDBC

 Batch Processing in JDBC Code:: for explanation watch video : package com.jdbc; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Statement; public class OracleConn { public static void main(String[] args) { try (Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl", "system", "tiger"); Statement st = con.createStatement()) { // add queries to batch ..these queries can belong to same db table or different // db tables but must be non-select Queries st.addBatch("INSERT INTO STUDENT VALUES(4444,'david',55.77,'france')"); st.addBatch("UPDATE  STUDENT SET AVG=AVG+10 WHERE SNO=2"); st.addBatch("DELETE FROM STUDENT WHERE SNO=1"); // execute the batch int result[] = st.executeBatch(); // find sum of the records that are effected int sum = 0; for (int i = 0; i < result.length; ++i)...

Session tracking using Http Cookies

 Session tracking using Http Cookies index.html ======== <!DOCTYPE html> <html> <head> <meta charset="ISO-8859-1"> <title>Insert title here</title> <style type="text/css"> div { width: 500px; margin: auto; margin-top: 100px; } </style> </head> <body> <div> <form action="firsturl" method="post"> Name: <br> <input type="text" name="name"> <br> Choose any one: <br> <select name="dish"> <option value="sweet">Sweet</option> <option value="spicy">Spicy</option> </select> <br> <input type="submit" value="submit"> </form> </div> </body> </html> FirstServlet.java ------------------- package com.servlet; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.Servl...

Weather Observation Station 18 Hackerrank Solution - SQL

Weather Observation Station 18 Hackerrank Solution - SQL For explanation watch video :: Code:: select round(abs(max(lat_n)-min(lat_n))+abs(max(long_w)-min(long_w)),4) from station;