Sunday, October 31, 2004

First contact with Oracle Database XE

Oracle Database 10g Express Edition Beta Release is now available for download, from OTN:


What is this new release, you can find more information on the Oracle XE page, that I quote:
exp_edi_wht.gif Oracle Database XE is a great starter database for:
  • Developers working on PHP, Java, .NET, and Open Source applications
  • DBAs who need a free, starter database for training and deployment
  • Independent Software Vendors (ISVs) and hardware vendors who want a starter database to distribute free of charge
  • Educational institutions and students who need a free database for their curriculum


This first contact with the latest release of the Oracle database is really great, the 150Mb download is really quick...
The installation is really easy... I have created a viewlet driving you through the installation.

As you can see in the viewlet, at the end of the installation you have a running database that you can fully administer from your browser, you can also create CRUD application using HTMLDB... And obviously you can connect your J2EE application server to it and start creating applications...

Screeshots:

Admin Menu

Object Browser

Resources:

Thursday, October 28, 2004

Oracle Application Server, and OC4J Certification

If you ask yourself on which Operating Systems, JDK, Browser, etc... you can use Oracle Application Server 10g just consult OTN or Oracle Metalink:

Tuesday, October 26, 2004

Mike Keith about Java2 5.0 Annotations

Mike Keith,architect for Oracle Containers for J2EE (OC4J) and TopLink products and currently represents Oracle in the EJB 3.0 expert group, has published an interesting article about Annotations in Java 5.0:. To Annotate or Not? focused on the usage of Annotation or XML as metadata language. Mike provides sample code and explain the pros and cons of the annotation using use cases.

Thursday, October 7, 2004

New Dynamic Menu for OracleAS Portal 10g

Ronaldo Viscuso has just released a new version of his DHTML Menu Portlet. This portlet generates a DHTML menu for site navigation, with links to pages and subpages from a selected page group.
Stylesheet, height, width, mouse-over behavior, etc. are all configurable via the "Edit Defaults" page, which allows for complete customization for pretty much any desired look & feel....
The portlet, screen shots and installation document are available on the Portal Knowledge Exchange.
87493.JPG

Wednesday, October 6, 2004

Jive portlets for OracleAS Portal

An Oracle Application Server (OracleAS) Provider for Jive Forums is now available to download from the Portal Integration Solutions page on OTN. The Oracle Application Server (OracleAS) Provider for Jive Forums contains portlets that allow users and administrators to:

  • View topics posted on their favorite forums
  • Create a new topic or post a reply to one
  • Search the forums
  • View the hot topics across all forums
  • View all topics, forums, categories and users being watched by the user
  • View top reward points earners
  • Administer the Jive Forums Application

Looking for articles: use JavaPro magazine collection

You are looking for a articles about J2EE, JavaPro magazine put online a nice tool to search and view all the published articles:

Monday, October 4, 2004

Groovy, Java's New Scripting Language

Groovy, Java's New Scripting Language by Ian F. Darwin -- When some Java developers hear about Groovy, their first reaction is often, "Oh, no, not another scripting language for Java." Ian Darwin had the same reaction, until he took a good look at Groovy.

Sunday, October 3, 2004

Good taste tool: del.icio.us

I am starting to use del.icio.us. A great way to manage your own bookmarks but also to share them with others... It is fun to see how many people are sharing the same bookmarks as you, and help you to find information related to the different categories... Also the integration with Firefox using the delicious plugin make the usage of the bookmark manager very easy. You can also use theApple Mac OS X client for del.icio.us. Here my bookmarks... still working on it

Friday, October 1, 2004

Sample Code: BLOB insertion in Oracle10g

Responding to a customer question about Blob insertion in Oracle 10g DB using the JDBC 3.0 driver. Very Simple application. Download Java Source See insertBlob method.

package demo;

import java.sql.*;
import java.io.*;
import java.sql.PreparedStatement;
import java.util.*;

import oracle.jdbc.driver.*;
import oracle.sql.BLOB;



/**
 * Insert record in the MEDIA table 
 *   MEDIA (file_name varchar2(256), file_content BLOB);
 */
public class BlobOracle 
{
  private final static String hostname = "localhost";
  private final static String port = "1521";
  private final static String sid = "ORCL";
  private final static String username = "scott";
  private final static String password = "tiger";
  private static String fileLocation;
  private static Connection connection;

  public BlobOracle()
  {
  }

  /**
   * 
   * @param args
   */
  public static void main(String[] args)
  {
    try 
    {
      if (args.length == 0)
      {
       System.out.println("\n\n  Usage demo.BlobOracle ");
       System.exit(0);
      }
  
      fileLocation = args[0];
  
      setConnection();
      insertBLOB();
  
    } catch (Exception ex) 
    {
      ex.printStackTrace();
    } finally 
    {
    }
  }


  private static void setConnection() throws SQLException
  {
      DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
      connection = DriverManager.getConnection("jdbc:oracle:thin:@"+hostname+ ":"+ port +":"+ sid , username , password);
      connection.setAutoCommit(false); // we must control the commit
  }

  private static void insertBLOB() throws SQLException, Exception
 {
    BLOB blob;
    File file ;
    FileInputStream is;
    OutputStream os;

      long ts1 = System.currentTimeMillis();


      //Create a statement.
      PreparedStatement pstmt = connection.prepareStatement("insert into media (file_name, file_content) values (?,empty_blob())");
      file = new File(fileLocation);
      String fileName = file.getName();
      //Set the file name and execute the query
      pstmt.setString(1, fileName);
      pstmt.execute();

      //Take back the record for update (we will insert the blob)
      //supposely the file name is the PK
      pstmt = connection.prepareStatement("select file_content from media where file_name = ? for update");
      pstmt.setString(1, fileName);
  
      //Execute the query, and we must have one record so take it
      ResultSet rset = pstmt.executeQuery();
      rset.next();

      //Use the OracleDriver resultset, we take the blob locator
     blob = ((OracleResultSet)rset).getBLOB("file_content");

     is = new FileInputStream(file); //Create a stream from the file
     // JDBC 2.0
     //os = blob.getBinaryOutputStream(); //get the output stream from the Blob to insert it
     // JDBC 3.0
     os = blob.setBinaryStream(0); //get the output stream from the Blob to insert it
 
      //Read the file by chuncks and insert them in the Blob. The chunk size come from the blob
      byte[] chunk = new byte[blob.getChunkSize()];
      int i=-1;
      System.out.println("Inserting the Blob");
      while((i = is.read(chunk))!=-1)
      {
        os.write(chunk,0,i); //Write the chunk
        System.out.print('.'); // print progression
      }

      // When done close the streams
      is.close();
      os.close();

      //Close the statement and commit
      pstmt.close();
      long ts2 = System.currentTimeMillis();

      connection.commit();
      connection.close();
  
      System.out.println("\n"+ (ts2 - ts1) +" ms" );      
  

  }


}