Posts

Showing posts from July 5, 2018

| have added MySQL Connector to libraries , but still getting error 'java.lang.ClassNotFoundException: com.mysql.jdbc.driver' [duplicate]

| have added MySQL Connector to libraries , but still getting error 'java.lang.ClassNotFoundException: com.mysql.jdbc.driver' [duplicate] This question already has an answer here: import java.io.IOException; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; /** * Servlet implementation class LoginChek */ @WebServlet("/LoginChek") public class LoginChek extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public LoginChek() { super(); // TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequ

Enumerate the basic data types in C so that the sizes can be easily accessed

Enumerate the basic data types in C so that the sizes can be easily accessed Is it possible to get sizes of all basic datatypes in C using a for loop? For example, can we do something like this? #include <datatypes.h> /* or something else which defines get_data_types() */ #include <stdio.h> int main() { for (int x = 0; x < len(get_data_types()); x++) { printf("Size of %s is %d", get_data_types()[x], sizeof(get_data_types()[x])); } } I could enumerate all the datatypes by replacing the for loop and writing individual statements for int , long , etc. However, I am wondering if it is possible to have a for loop to do the same? int long Essentially, I am trying to avoid the following: #include <stdio.h> int main() { printf("Size of int is %d", sizeof(int); printf("Size of unsigned int is %d", sizeof(unsigned int); printf("Size of long is %d", sizeof(long); /* etc. */ return 0; } Data types of

Java generics for optional single value or collection

Java generics for optional single value or collection I'm trying to define a container for a whole bunch of classes as some parts of the code will make more sense with a collection but other places will make sense with single values. Ideally I'd like to do this: public class AllModes<T> { private T<Car> car; private T<Boat> boat; private T<Train> train; private T<Plane> plane; ...40 more of these... } then I'd like to use the class like: AllModes<List> allModes; AllModes<Optional> oneOfEachMode; But I get the error I get is "The type T is not generic; it cannot be parameterized with arguments " The reason I'm defining these in multiple variables and not a single HashSet based on a superclass is I want to have get methods that return the correct types to avoid consumers of this class needing to cast down everywhere as each object has its own distinct fields. I also considered just storing a single value l

Position 2 headers in the middle of 2 panel

Position 2 headers in the middle of 2 panel I have this code below that consists of 2 panels and 2 header what i'm trying to accomplish is to put the total fruits header in the middle of the left panel and the other header on the right. But whenever i try to put them in the centre it just messes up the whole thing is there a correct way to do this because i'm not sure how to go about it any suggestion would be greatly appreciated. total fruits var redpill = {}; var greenpill = {}; var randompill = {}; var key = "Red Fruits"; redpill[key] = ['Apple', 'Cherry', 'Strawberry', 'Pomegranate', 'Rassberry', 'Watermelon', 'Durian', 'Avacado', 'Lime', 'Honeydew', 'Watermelon','Apple', 'Cherry', 'Strawberry', 'Pomegranate']; var key2 = "Green Fruits"; greenpill[key2] = ['Watermelon', 'Durian', 'Avacado', 'Lime', '

REST API with Single Page Application over HTTPS on Firefox only

REST API with Single Page Application over HTTPS on Firefox only I am developing a web service using REST API. This REST API is running on port 6443 for HTTPS. Client is going to be a Single page application running on port 443 for HTTPS on same machine. The problem I am facing is: While I hit the url say: https://mymachine.com/new_ui I get certificate exception for an invalid certificate because I use a self signed one, so mymachine.com:443 gets added to server exception. But still requests doen't go to REST API as they are running on https://mymachine.com:6443/restservice. If I manually add mymachine.com:6443 to server exception on firefox it works but it will not be the case in production for customers. Some options that I thought are: 1. Give another pop up and ask to add REST server on port 6443 exception too.But this doesn't look proper as why an end user should accept the cerf for same domain twice. Also REST api server port can change. Please suggest some options. How

Laravel casting exponent to float not working

Laravel casting exponent to float not working I have a very small number 0.00000064 that has the datatype of double(20,8) . I am seeing the number as 6.4E-7 . 0.00000064 double(20,8) 6.4E-7 In my model I am trying to cast column as follows: protected $casts = [ 'total_crypto_balance' => 'float' ]; but I am still receiving that exponent number back. to receive the number 0.00000064 in view and not the exponent 6.4E-7 . 0.00000064 6.4E-7 What am I doing wrong here? Possible duplicate of php- floating point number shown in exponential form – Namoshek Jul 1 at 7:26 @Namoshek - not really, nothing to do with Laravel casting. YET - if you can derive an answer from that into a viable Laravel eloquent solution, I will vote you as answer. – erezt Jul 1 at 7:29

Azure SQL DB causing connection time out for stored procedures

Azure SQL DB causing connection time out for stored procedures We have hosted our database in Azure and are running stored procedures on this DB. The stored procedures had been running fine till last week but suddenly started giving error connection timeout. Our database size is 14 GB and the stored procedures in general return 2k to 20k records and we are using the S3 pricing tier (50 DTU) of Azure DB. What I found interesting was the first time the stored procedure is executed, it takes a lot of time 2 - 3 mins and this is causing the timeout. The later executions are fast (maybe it caches the execution plan). Also when I run on the same DB with the same number of records on a machine with the config of 8gb ram, Win10 it runs in 15 seconds . This is my stored procedure: CREATE PROCEDURE [dbo].[PRSP] @CompanyID INT, @fromDate DATETIME, @toDate DATETIME, @ListMailboxId as MailboxIds Readonly, @ListConversationType as ConversationTypes Readonly AS BEGIN

using forward declarations instead of void* C++

using forward declarations instead of void* C++ Is it possible to use a forward declarations instead of void* or the preference is to use typedef ? I am using a Specific class in my API. for the clients who use it, the class is represented by void* so the clients would not need to use the header files. void* Which of these choices is better? class A; class b { A* simple; }; or typedef void* A; class b { A simple; }; Those are three completely different things... – Rakete1111 Jul 1 at 7:41 Use them where? C++ is not a "one approach fits all" kind of language. – StoryTeller Jul 1 at 7:43 I honestly don't know how they ar

How to superimpose a canvas on an HTML5 video using object-fit cover?

How to superimpose a canvas on an HTML5 video using object-fit cover? I am refactoring this code: https://github.com/idevelop/predator-vision to superimpose heatmap on a video (with any resolution and aspect-ratio). I have the following html code: <div id="videos" class="embed-responsive"> <canvas id="heatmap" class="embed-responsive-item"></canvas> <video id="remote-video" autoplay muted playsinline class="embed-responsive-item"></video> </div> CSS: #remote-video { display: block; height: 100%; max-height: 100%; max-width: 100%; position: absolute; top: 0; left: 0; object-fit: cover; /* no letterboxing */ opacity: 1; -moz-transform: rotateY(180deg); -ms-transform: rotateY(180deg); -o-transform: rotateY(180deg); -webkit-transform: rotateY(180deg); transform: rotateY(180deg); transition: opacity 1s; width: 100%; } #re

Can't receive PHP object by using AJAX

Can't receive PHP object by using AJAX I can't fetch the php file from the ajax. Firstly an object is created in the PHP file, then it is converted into JSON by using json_encode() function. The problem is: when I request that PHP file from ajax, nothing is shown as an output. ('Smith' is supposed to be an output though) Here is my php file: 1.php <?php $myObj->name = "Smith"; $myObj->age = 20; $myObj->Address = "Yangon"; $myJSON = json_encode($myObj); echo "$myJSON"; ?> Here is ajax file: ajaxfile.php <p id="demo"></p> <script type="text/javascript"> var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function(){ if (this.readyState == 4 && this.status == 200) { var myObj = JSON.parse(this.responseText); document.getElementById("demo").innerHTML = myObj.name; } }; xmlhttp.open(&q

I want to restrict job seeker update/view his mysql data until admin panel approve his profile

I want to restrict job seeker update/view his mysql data until admin panel approve his profile This is the code I used but its for admins in the mysql not for a user(job seeker) in my website. REVOKE SELECT ON contacts FROM '*'@'localhost'; Where is the code and what do you want to achieve? – Nico Haase Jul 1 at 7:51 this makes very little sense – smith Jul 1 at 8:03 You have to restrict this feature on application level, not on database level, since I doubt that you create a separate mysql user acvount for each of your users. – Shadow Jul 1 at 8:23

Replacing busy loop and sleep in thread

Replacing busy loop and sleep in thread I have a Thread that calls a certain service. The service defines a callback function that can be called multiple times as long as there is data onProcessing(). The onCompletion() is called once it is finished. public CallThread implements Runnable{ public boolean isCompleted = false; public void run(){ ResponseObserver response = new ResponseObserver(){ public void onException(){ //Errors could happen sometimes so the program should just issue another request } public void onCompletion(){ isCompleted = true; //process the result } public void onProcessing(){ //This could be called multiple time } } //Service is the object that calls the service Service service = getService(); while(!isCompleted){ //Request object is populated Request req

How == and equal works in java in Case of Integer Object? [duplicate]

How == and equal works in java in Case of Integer Object? [duplicate] This question already has an answer here: I have found many possible duplicates question on this but none clarifies my doubt on how it works? Integer a =25654; // a.hashCode()=>25654 Integer b =25654; // b.hashCode()=>25654 System.out.println(a.equals(b)); => true System.out.println(a == b); => false I have read this answer somewhere.. If no parent classes have provided an override, then it defaults to the method from the ultimate parent class, Object, and so you're left with the Object#equals(Object o) method. Per the Object API this is the same as ==; that is, it returns true if and only if both variables refer to the same object, if their references are one and the same. Thus you will be testing for object equality and not functional equality. in this case both object have same memory address(as per hashcode) still why does it returns false when we compare using == ? or the actual