Tuesday, November 11, 2008

Callable statement not supported(Mysql)

Calling a stored procedure from a java.


String url = "jdbc:mysql://localhost/mysql";

con = DriverManager.getConnection(url, "root", "test");

catch(Exception e)
System.err.println("Exception: " + e.getMessage());

CallableStatement stmt = con.prepareCall ("{call cursorproc (?,?)}");
  • CallableStatement

    Starting with Connector/J 3.1.1, stored procedures are supported when connecting to MySQL version 5.0 or newer via the CallableStatement interface. Currently, the getParameterMetaData() method of CallableStatement is not supported.

  • Refer : http://dev.mysql.com/doc/refman/5.0/en/connector-j-reference-implementation-notes.html

  • Friday, November 7, 2008

    Select second highest salary from emp table. how to find second highest.

    select second highest salary from emp table
     select max(sal ) from emp where sal<(select max
    (sal)from emp)
     select max(sal) from emp where level=2 connect by prior
    sal>sal group by level;

    select the employee details who is having the second highest salary from emp table
     select A.* from emp A where 1=(select count(distinct
    B.sal) from emp B where B.sal>A.sal)
    select second highest salary of the employee along with first highest salary from emp table
    select ename,sal from
     (select ename,sal from emp
     order by sal desc)
     where rownum <=2;
    Some where i found this solution. it works.
    keywords: Select second highest salary from emp table. how to find second highest, pl/sql,oracle,mysql,sql server,database,9i,10g,query,doubt,where,blogspot.

    Thursday, November 6, 2008

    Assign Jsp variable to Javascript variable

    <% String strJspVariable="mohan"; %>
    var strJavaScriptvariable=<%=strJspVariable%>;

    Wednesday, November 5, 2008

    prevent double click form submit (double click on form submit problem)


    put this at the  end of your submit button.

    sample code

    <input  type="submit"   value="Submit"  onclick="this.disabled=true,this.form.submit();" />

    Tuesday, November 4, 2008

    difference between Servlets and JSPs


    difference between Servlets and JSPs

     JSP's main concern is to prevent developers coding the HTML code inside java (i.e : within servlet). So it has many features like EL,JSTL,Standard Actions etc... But After all JSP becomes a servlet in the container when serving the client requests.