Sunday Sep 07, 2008

http://kenai.com - Developer Collaboration Platform Released!

  • Checkout http://kenai.com - Developer Collaboration Platform just released!
  • Built using JRuby, Deployed on Glassfish V2, using MySQL - all on Sun Technologies and Products
  • Email me, if you would like an invite to be able to create projects there
  • It can house subversion and Mercurial repositories for your projects
  • You can have bugzilla, mailing lists, forums and wiki's for your project
  • You could use your Sun Developer Network account to login there
  • You could email to users@help.kenai.com and or post your comments/issues you might have at: http://kenai.com/projects/help/lists
  • Friday Jun 23, 2006

    How to use Oracle Sequence for auto increment column

    While reading through this thread http://forum.sun.com/jive/thread.jspa?threadID=99306 I had to check out how to invoke sequence.nextval for new row being appended.


    Here's how i did achieve this:

    1. Created a Sequence and a Table:
    CREATE SEQUENCE userid_seq MINVALUE 1 START WITH 1 INCREMENT BY 1 NOCACHE;
    create table user_seq_test ( seq_col int not null primary key, char_col char(10) );

    2. Creating a Page to append rows into this table:
    Add a datadource (say ora9i) to access this database table in Servers Window. Create a New Project, drag and drop user_seq_test table onto page. Dropa text field and bind it to user_seq_test.char_col. Add a button for "Append Row". Add a message group to be able to see the error messages on the page, when it happens.

    In the prerender, append a row to the dataprovider and get the sequence value for the new row and set it:
    try {
        RowKey rk = user_seq_testDataProvider.appendRow();
        user_seq_testDataProvider.setCursorRow(rk);
                
        Connection conn = null ;
        Statement sqlStatement = null ;
        ResultSet rs = null ;
                
        javax.naming.Context ctx = new javax.naming.InitialContext() ;
        DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/ora9i") ;                      
        conn = ds.getConnection() ;                        
        // setup the connection             
        conn.setAutoCommit(true) ;                         
        // execute the query            
        sqlStatement = conn.createStatement() ;
        rs = sqlStatement.executeQuery("select userid_seq.NEXTVAL from dual" ) ;
        rs.next() ;
        int nextvalue = rs.getInt(1) ;
        user_seq_testDataProvider.setValue("seq_col", new Integer(nextvalue));
        rs.close();
        sqlStatement.close();
        conn.close();
            } catch (Exception ex) {
                error(ex.getMessage());
                log("Error Description", ex);
            }
    
    In the append Row Button action:
    try {
                user_seq_testDataProvider.commitChanges();
                user_seq_testDataProvider.refresh();
            } catch (Exception ex) {
                log("Error Description", ex);
                error(ex.getMessage());
            }
    

    So, when we want to use Sequence.NEXTVAL, you need to fetch the value and set this value on the auto-increment column in the appended row.

    We could use similar technique for calling functions and stored procedures.

    Wednesday Jun 07, 2006

    Fast Track (3 days) Learning - WebApps and Portlets Development using Java Studio Creator

    If you are craving to get started or understand deeper with Java Web Application and Portlet Development, this Threee Day Fast Track Course will be the awesome event for you!

    • You will get this Field guide.
    • This workshop is loaded with lots of exerices with explains building web applications and portlets very quickly.
    • Building Web Applications with Creator using JAX Components is the HOT thing!
    • This will give you indepth understanding of various technologies like JavaServer Faces, JDBC rowsets, dataproviders.

    Monday Feb 06, 2006

    Sun Studio 11 Developers - Get Expert Assistance for FREE!

    The Sun Developer Tools Organization is sponsoring a new pilot on-line service: Per Incident Developer Support for Sun Studio 11. This service is now live on SDN and can be accessed at:


         http://developers.sun.com/developer_help/

    For this pilot phase, the cost per incident for developers is $0 (yes, FREE). YAY!!!

    About

    sakthi

    Search

    Archives
    « April 2014
    SunMonTueWedThuFriSat
      
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
       
           
    Today