Tag: Oracle


Clobs in Oracle 10g

May 4th, 2009 — 1:16pm

CLOB is the Oracle’s data type used for storing large textual data objects.

There is a problem when using standar APIs for processing CLOB data, it is that PreparedStatement.setString() only allows to process strings up to 32765 byte. To solve it, Oracle 10g has introduced a new property called SetBigStringTryClob that allows developers to use the standar JDBC PreparedStatement.setString() and ResultSet.getString() functions for also processing CLOB data.

Next snippet shows how to achieve CLOB handling by setting new property when creating the connection:

import java.sql.Connection;
import java.sql.DriverManager;
import oracle.jdbc.OracleDriver;
import java.util.Properties;
..........

// Load the database details into the variables.
String url      = "jdbc:oracle:thin:@localhost:1521:orcl";
String user     = "scott";
String password = "tiger";

// Create the properties object that holds all database details
Properties props = new Properties();
props.put("user", user );
props.put("password", password);
props.put("SetBigStringTryClob", "true");

// Load the Oracle JDBC driver class.
DriverManager.registerDriver(new OracleDriver());

// Get the database connection
Connection conn = DriverManager.getConnection( this.url, this.props );

This new property forces the preparedStatement.setString() to use another newly introduced method, OraclePreparedStatement.setStringForClob(), which can be used alone instead of the standar APIs.  See how:

 import java.sql.*;
import java.io.*;
import java.util.*;
import oracle.jdbc.*;
import oracle.jdbc.pool.*;
..........

// Create SQL query to insert CLOB data and other columns in the database.
String sql = "INSERT INTO clob_tab VALUES(?)";

// Read a big file(larger than 32765 bytes).
// Note: method readFile() not listed here.
// It can be any method that reads a file.
String str = this.readFile("bigFile.txt");

// Create the OraclePreparedStatement object
opstmt = (OraclePreparedStatement)conn.prepareStatement(sql);

// Use the new method to insert the CLOB data (for data greater or lesser than 32 KB)
opstmt.setStringForClob(1,str);

// Execute the OraclePreparedStatement
opstmt.executeUpdate();
...........

Taken from:  Handling Clobs in Oracle 10g

Comment » | Oracle

How to get Oracle’s charset

March 11th, 2009 — 7:56am

INVEMAR has bought a new server which is being installed to replace the current Oracle’s server.  During this process I have being asked several times about getting the Oracle’s charset and I guess I have searched for it a million times, so I decided to post this to avid the searching process next time.


SELECT value$

FROM sys.props$ 

WHERE name = 'NLS_CHARACTERSET'

Comment » | Oracle

Starting upgrading Content Management System

February 19th, 2009 — 5:19pm

INVEMAR has its own Content Management System, now it is time to develop a new version of that, and that is my new target.

This task has so many interesting things to do, starting from the graphic desing, user profiles, new modules, upgrading and improvement of existing modules, among others.

Today I have been working in the new User Profile schema (there was a very basic one), during morning I was drawing data base tables and relationships (entity-relationship model, the small one necesary for the module).  They were seven tables in total and now I am ready to start developing related classes and interfaces.  I have many ideas in my head, I want to use a nice implementation of MVC (Model View Controler) wheter it is one of my own or one of them you find in the web (Struts, JSF, etc). The point is that I want to do a better thing than the last project, thats the idea when you start something new, do things better, and better, and improve, LEARNING, that is the goal.

So, I am very excited with this, I am working in this project with Oracle, Java, JSP, AJAX (Javascript frameworks).

Today it is a special day because I have been six month working at INVEMAR, so I am very happpyyyyyyy.

So see you tomorrow.

PD:  Tomorrow I will introduce you to GED.

1 comment » | My land

Back to top