Tuesday, June 8, 2010

GWT Canvas

In my recent adventure about using GWT canvas to draw some images at work lead me to one discovery. Lets assume that we are trying to draw a polygon, so we will use following code

canvas = new GWTCanvas(500,500);
canvas.setFillStyle(color);
canvas.beginPath();
canvas.moveTo(100, 500);
canvas.lineTo(150, 400);
canvas.moveTo(150, 400);
canvas.lineTo(450, 400);
canvas.moveTo(450, 400);
canvas.lineTo(500, 500);
canvas.moveTo(500, 500);
canvas.lineTo(100, 500);
canvas.closePath();
canvas.stroke();
canvas.fill();


This will draw the polygon but will not fill it with the Color that we have set as fill style. If one comments out the lines corresponding to moveTo() method, the fill() method works and fills the polygon with the color that we have specified.

Wanted to share.
Cheers!!

Friday, March 19, 2010

SQLException: Protocol violation - A possible solution

Sometime ago at work I encountered an exception while inserting a row in a table.
We kept seeing following exception
when we were trying to insert a new row in a table using jdbc (using ojdbc14.jar and oracle 9 as database). DBA tried creating the table
again, she could run the query well in sqlplus, golden.

java.sql.SQLException: Protocol violation at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112) at
oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java: 146) at
oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java: 208) at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:764) at
oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:216)
oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:955)
oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1168)
oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3285)
oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3390)
com.myCompany.myPackage.MyDao.insert(MyDAO.java:122)

The table in which we were trying to do an insert looked as followed

FIELD | TYPE | CONSTRAINT | ADDITIONAL CONSTRAINT |
PERSON_ID | NUMBER| PRIMARY KEY |SEQUENCE GENERATED ID |
CREATED_ON | DATE | NOT NULL |
STATUS| VARCHAR (1)| NOT NULL | THE VALUES ARE EITHER 'A' OR 'I'|
LAST_NAME| VARCHAR (100)| NOT NULL | |

The query was something like following

INSERT INTO PERSON (LAST_NAME,STATUS) VALUES (?,'A');

When we replaced query following query, it worked smooth.

INSERT INTO PERSON (NAME,STATUS) VALUES (?,?);

Apparently we cannot insert into table when there is an static value in
the statement using jdbc. This solution was not found in any google search at that time,
may be this blog post will help anybody who encounters it :)

Note: The queries and table in this blog are changed so as to protect the intellectual property.

Wednesday, February 3, 2010

Snow Leopard, Safari 4.0.4 and GWT

If you encounter this issue (http://code.google.com/p/google-web-toolkit/issues/detail?id=4220) about running your gwt app on snow leopard with safari 4.0.4, try this solution (http://grack.com/blog/2009/11/16/fix-for-gwt-hosted-mode-crash-with-safari-4-0-4/). It works. I spent few hours finding it, so thought would share.

Friday, January 1, 2010

10 Most populart programming articles in 2009

I found this list here

I will also enumerate the articles which I loved in 2009, in few days!

Happy New Year to everyone...