Monday, August 31, 2009

Multi select transfer using JQuery

JQuery is very good GUI tool
They are many components which can be easily developed by JQuery.
1) Easy Multi Select Transfer from one text box to other can be done ealiy in JQuery.

$().ready(function() {
$('#add').click(function() {
return !$('#select1 option:selected').remove().appendTo('#select2');
});
$('#remove').click(function() {
return !$('#select2 option:selected').remove().appendTo('#select1');
});
});

2) How to find the length of the selected options in the Multi selection
var options = jQuery("#select2 option:selected");
var length = options.length;

Friday, August 28, 2009

Eclipse DB pulgins

Hi,
I have observed few things in Ecplise Gynamade
when we run stored procedure in Eclipse, It will give syntax error, the same stored procedure when excuted using in the Toad or DBViusalizer , it works perfectly
Example :
CREATE PROCEDURE TestProcedure(IN parameter1 VARCHAR(4), IN parameter2 TEXT)
BEGIN
DECLARE p1 INT DEFAULT 1;
END
when we excute the same procedure using Ecplise, we get the syntax error,
When we excute the same procedure using DBVisualizer, It works fine.
Solution :
So, Don't waste time on excuting the stored procedure in Eclipse. :-)

Regards,
DeepthiMahesh.

Thursday, August 27, 2009

Java - Hibernate - MYSQL

Hi,
In this blog, I want to share my experience when I am using hibernate
Hibernate is very good framework which makes developer work very easy, but when we are doing some stuff like calling some stored procedures etc, we will face some issues
I have listed out some issues which I faced.
This we can do in two ways
1) Normal JDBC call.
Code:
Connection con = getSession().connection();
String CompIDList = compList.toString();
java.sql.CallableStatement st = con.prepareCall(" { CALL Test (?, ?) } ");
st.setString("tagName", tag.getName());
st.setString("comList",compList);
st.execute();

The issuses when we are using the above method.
When we don't have proper premission on the server. we will face the following issuses
Error :
at java.lang.Thread.run(Unknown Source)
java.lang.NullPointerException
at com.mysql.jdbc.StringUtils.indexOfIgnoreCaseRespectQuotes(StringUtils.java:948)
at com.mysql.jdbc.DatabaseMetaData.getCallStmtParameterTypes(DatabaseMetaData.java:1255)
at com.mysql.jdbc.DatabaseMetaData.getProcedureColumns(DatabaseMetaData.java:3640)
at com.mysql.jdbc.CallableStatement.determineParameterTypes(CallableStatement.java:506)
at com.mysql.jdbc.CallableStatement.(CallableStatement.java:401)
at com.mysql.jdbc.Connection.parseCallableStatement(Connection.java:4072)
at com.mysql.jdbc.Connection.prepareCall(Connection.java:4146)
at com.mysql.jdbc.Connection.prepareCall(Connection.java:4120)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

Sloution :
Just the premissions of the user to admin.
or
provide the username & password with admin premissions.


2) Using the hibernate
code :
Query query = getSession().getNamedQuery("createTagging");
query.setParameter(0, tag.getName() );
query.setParameter(1, compList );
System.out.println("TagDAO.createTag() .... "+query);
query.executeUpdate();

Error :
4:54:01,978 ERROR hibernate.TagDAO:182 - save failed
java.lang.IllegalArgumentException: callable not yet supported for native queries
at org.hibernate.engine.query.NativeSQLQueryPlan.performExecuteUpdate(NativeSQLQueryPlan.java:147)
at org.hibernate.impl.SessionImpl.executeNativeUpdate(SessionImpl.java:1163)
at org.hibernate.impl.SQLQueryImpl.executeUpdate(SQLQueryImpl.java:334)

Solution:
Update the hibernate jars with latest version.