Search This Blog

Wednesday, April 25, 2012

name lookup timed out for https://graph.facebook.com

This problem has two solutions:
  1.  In the base_facebook.php, you will find api-read.facebook.com.Try to ping it through command line. If it does not respond change it to api.facebook.com in base_facebook.php.
  2. If the above didn't work, revert it back and change CURLOPT_CONNECTTIMEOUT => 10 to CURLOPT_CONNECTTIMEOUT => 60

Hope  this works!

Source : http://stackoverflow.com/questions/5114597/how-to-solve-problem-of-curlexception-6-name-lookup-time-out-error-in-facebook

Thursday, September 8, 2011

Easy way of making a JSON array of JSONarrays of JSONObjects ans so on ... in JAVA


In my code, I had to make a JSONArray of JSONArrays which have JSONObjects which in turn can be JSONArrays.
When we try to do it in pure JSON way, it gets complicated, we have to create a lot of different variables and then add it to the main array.
There is a very simple way to do it. Just keep on creating a HashMap which can be a HashMap of HashMaps and so on.
Then when you create a JSONArray pass the HashMap to it as a variable to its constructor. It creates an entire JSONArray from it.

Thanks,
Shoeb

#1241 - Operand should contain 1 column(s)


I was trying to run an insert statement something like:
insert into database.table(column1,column2) values ((a,b),(c,d),(e,f));
When i tried to execute this using java code, i got the following error:
#1241 - Operand should contain 1 column(s)

In this case, the error was:
I had added extra round brackets to club all the rows to be inserted which is wrong.
So the correct statement is:
insert into database.table(column1,column2) values (a,b),(c,d),(e,f);

The values were then inserted properly.
There is a possibility that you code has some other issue!

Thanks,
Shoeb

Wednesday, September 7, 2011

Maven system dependency.


Adding a depedency from the system is not recommended. The sole purpose of having maven is, if you give the developer the src directory and the pom.xml file, with the help of maven he can build and deploy the entire app.Having a system dependency will take away this advantage as you will have to provide the dependency along with the source or the developer will have to download it make changes to his pom.xml so that it takes the appropriate system path, etc.

System dependency should only be used if the dependency that you are providing cannot be found in any online repository or you are using some external functionality that you built yourself.

In one of my posts, I have explained how to add the system dependency.

Thanks,
Shoeb

Adding a new repository in the maven pom.xml


At times, the repository used in the pom.xml may not have the latest version of jar you are looking for. In such case, you will need to add a repository which has the required version of the particulaar dependency. You can do it in the following way:

Add the following lines between the <repositories> </repositories> tags:
<repository>
<id>org.spring.maven.snapshot</id>
<name>Spring Maven Snapshot Repository</name>
<url>http://repo1.maven.org/maven2/</url>
<releases><enabled>false</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>

Change the url and id according to your requirement. The id can be anything but should be a unique one.

Thanks,
Shoeb

Tuesday, August 23, 2011

Adding external Dependency jar in A Maven project -java via Eclipse/Springsource

Hi,

I was facing a lot of problems when adding an external dependency like jar files in a Maven project.
Here are the steps that I have figured out:

1. Download the required jar.
2. Open the pom.xml (in eclipse or SpringSource or any text editor)
3. Add the following entry:
Group ID : Any suitable group ID
Artifact ID : Any Suitable ID
Version : Apropriate
type : Jar
Scope : System
Path : The path where the jar is saved along with the jar name. Eg /home/ubuntu/Downloads/abc.jar
4. Save the pom file.
5. Right click the POM file -> run as -> Maven generate sources
6. Right click the POM file -> run as -> Maven install
7. Done!

Happy coding!
Shoeb

Class not found Exception for com.mysql.jdbc.Driver

Hi,

When ever the ClassNotFoundException for com.mysql.jdbc.Driver,
make sure you have added the mysql-connector-java-5.1.17.jar (available on mysql site) in the jre/lib/ext directory.
I was using it with my maven build Spring MVC project and was cursing it unnecessarily.

Happy coding,
Shoeb