Wednesday, August 28, 2013

Backbone: Request Method:OPTIONS Status Code:405 Method Not Allowed trying to do a POST request with collection.fetch

I had this code:

this.organizationServicesCollection.url = 'http://localhost/SkyDesk.Services/SrvService.svc/rest/service/queryservices/'        
var fetchParameters = {
data: JSON.stringify({
    parameters: {'key':'value'}
}),
        type: 'POST',
        contentType: 'application/json'
};
this.organizationServicesCollection.fetch(fetchParameters);

when executed I was having two resulting requests:

Request URL:http://localhost/SkyDesk.Services/SrvService.svc/rest/service/queryservices/
Request Method:OPTIONS

Request URL:http://localhost/SkyDesk.Services/SrvService.svc/rest/service/queryservices/
Request Method:POST

The problem was that my current proyect was being run in http://localhost:49998/ instead http://localhost/ so there was a cross domain issue. I fixed it running my project in http://localhost/ , now when running the code I had my single POST request:

Request URL:http://localhost/SkyDesk.Services/SrvService.svc/rest/service/queryservices/
Request Method:POST

Tuesday, August 27, 2013

JSON: Online Json pretty printer

Here is a nice and simple online json pretty printer:
http://jsonprettyprint.com/

Friday, August 23, 2013

Convert epub to pdf

Zamzar is great and a free online file conversion site : http://www.zamzar.com/

Oracle Certified Associate, Java SE 7 Programmer 1Z0-803 Java SE 7 Programmer I : Recommended books

Here are a couple of recommended books to study for the Oracle Certified Associate, Java SE 7 Programmer 1Z0-803 Java SE 7 Programmer I Certification Exam:

OCA Java SE 7 Programmer I Study Guide (Exam 1Z0-803) (Oracle Press)
OCA Java SE 7 Programmer I Certification Guide: Prepare for the 1ZO-803 exam

Java Sockets: Simple client and server example source files

The explanation of the source code is here:
http://docs.oracle.com/javase/tutorial/networking/sockets/

You can donwload the source code here
http://www.oracle.com/technetwork/java/javase/downloads/java-se-7-tutorial-2012-02-28-1536013.html

1. Download and unzip the javatutorials.zip file
2. Go to \javatutorials\tutorial\networking\sockets\examples

Now you can access the source files to run the example.



Jquery: select element by name

Thursday, August 22, 2013

SQL Server 2008: Invalid object name SQL Server 2008 R2

I was getting the error:

Internal Exception: com.microsoft.sqlserver.jdbc.SQLServerException: Invalid object name 'TRANSACCION'. Error Code: 208

The problem was that the table wasn't created in the database, you can also verify the name of the table you´re trying to manipulate.

Resources:
http://social.msdn.microsoft.com/Forums/sqlserver/en-US/ec184168-ddd1-4df5-b2c7-c6671b602a3d/string-or-binary-data-would-be-truncated-and-field-specifications

Tuesday, August 13, 2013

SQL Server 2008: Cannot establish a connection. The server sqlexpress is not configured to listen with TCP/IP

I was getting the error:

Cannot establish a connection to jdbc:sqlserver://FEMPUTADORA-PC\SQLEXPRESS;databaseName=pichincha using com.microsoft.sqlserver.jdbc.SQLServerDriver (The server sqlexpress is not configured to listen with TCP/IP.)

I solved it by enabling TCP/IP listen:
1. Run: "start" > "all programs" > "Microsoft SQL server 2008" > "configuration tools" > "SQL Server Configuration Manager"
2. Go to SQL Server Network Configuration > Protocols for SQLEXPRESS.
3. enable TCP/IP.

Reference:
http://stackoverflow.com/questions/11278114/enable-remote-connections-for-sql-server-express-2012

SQL Server 2008: Cannot establish a connection. Verify the server and instance names, check that no firewall is blocking UDP traffic to port 1434, and for SQL Server 2005 or later verify that the SQL Server Browser Service is running on the host

I was getting the error:

Cannot establish a connection to jdbc:sqlserver://FEMPUTADORA-PC\SQLEXPRESS;databaseName=pichincha using com.microsoft.sqlserver.jdbc.SQLServerDriver (The connection to the host FEMPUTADORA-PC, named instance sqlexpress has failed. Error: "java.net.SocketTimeoutException: Receive timed out". Verify the server and instance names, check that no firewall is blocking UDP traffic to port 1434, and for SQL Server 2005 or later verify that the SQL Server Browser Service is running on the host.)

I solved it by enabling the SQL server browser:
1. Go to "start" > "contro panel" > "systems and security" > "administrative tools" > "services"
2. Right click in "SQL server browser" > propeties
3. Set Start up type as "automatic"
4. click on "start"
5. click on "ok"


SQL Server 2008: enable login to sa user

  1. Login using Windows Authentication and ".\SQLExpress" as Server Name
  2. Change server authentication mode - Right click on root, choose Properties, from Security tab select "SQL Server and Windows Authentication mode", click OK 
  3. Set sa password - Navigate to Security > Logins > sa, right click on it, choose Properties, from General tab set the Password (don't close the window) 
  4. Grant permission - Go to Status tab, make sure the Grant and Enabled radiobuttons are chosen, click OK 
  5. Restart SQLEXPRESS service from your local services
Source:

Monday, August 12, 2013

IIS8: Unable to star debugging on the web server

I was getting the followong error:

Unable to start debugging on the web server. The web server could not find the requested resource.

I solved the issue enabling ASP in the IIS:
1. Go to "Start" > "control panel" > "programs" > "Turn windows features on or off"
2. Wait while it loads
3. Enable the option : "Internet Information Services" > "world wide services" > "application development features" > "asp"
4. click "ok"

Sunday, August 4, 2013

Java: Simple sample of socket server using InetAddress

public static void main(String[] args) {
        // TODO code application logic here
        String hostIP = "127.0.0.1";
        InetAddress bindAddr; 
        try {
            bindAddr = InetAddress.getByName(hostIP);
            launchServerSocket(4567, 4568, bindAddr );
        } catch (UnknownHostException e) {
            System.out.println("Unknown Host: " + hostIP);
            e.printStackTrace(); 
        }                
    }
 
    public static void launchServerSocket(int portNumber, int backlog, InetAddress bindAddr ){
        try {
            ServerSocket serverSocket = new ServerSocket(portNumber, backlog, bindAddr);
            System.in.read();// prevent console to be closed
        } 
        catch (IOException e) {
            System.out.println("Could not listen on port: " + portNumber);
            e.printStackTrace();            
        }
    }

OAuth V 2.0 resources