Recent Notes

Displaying keyword search results 1 - 11
Created by meiu on February 09, 2010 03:26:14    Last update: March 31, 2011 09:00:19
Simple JDBC code for Oracle. import java.sql.*; public class JDBCHelloWo...
Created by Fang on August 16, 2010 22:00:05    Last update: August 16, 2010 22:12:25
The tags <sql:update> Executes SQL INSERT , UPDATE , DELETE statements, or SQL DDL statements. Syntax: <sql:update sql="sqlUpdate" [dataSource="d... or, put the SQL within the element body: <sql:update [dataSource="dataSource"] [v... Attributes: Name Dynamic? Type Description sql true String SQL update statement. dataSource true javax.sql.DataSource or String Data source associated with the database to update. A String value represents a relative path to a JNDI resource or the parameters for the JDBC DriverManager class. var false String Name of the exported scoped variable for the result of the database update. The type of the scoped variable is java.lang.Integer . scope false String Scope of var. Defaults to "page". <sql:transaction> Establishes a transaction context for <sql:query> and <sql:update> subtags. Syntax: <sql:transaction [dataSource="dataSource"] ... where...
Created by Fang on August 16, 2010 21:44:41    Last update: August 16, 2010 22:01:46
The tags <sql:query> Queries a database. Syntax: <sql:query sql="sqlQuery" var="varName" [scope... or, put the query within the element body: <sql:query var="varName" [scope="{page|req... Attributes: Name Dynamic? Type Description sql true String SQL query statement. dataSource true javax.sql.DataSource or String Data source associated with the database to query. A String value represents a relative path to a JNDI resource or the JDBC parameters for the DriverManager class. maxRows true int The maximum number of rows to be included in the query result. If not specified, or set to -1, no limit on the maximum number of rows is enforced. startRow true int The returned Result object includes the rows starting at the specified index. The first row of the original query result set is at index...
Created by Dr. Xi on February 09, 2010 04:54:10    Last update: February 09, 2010 04:54:10
Use this to connect to oracle RAC (Real Application Cluster): jdbc:oracle:thin:@(DESCRIPTION=(LOAD_BALANCE=on) ... From Oracle Database JDBC Developer's Guide : Specifier Supported Drivers Example Oracle Net connection descriptor Thin, OCI Thin, using an address list: url="jdbc:oracle:thin:@(DESCRIPTION= (LOAD_BALANCE=on) (ADDRESS_LIST= (ADDRESS=(PROTOCOL=TCP)(HOST=host1) (PORT=1521)) (ADDRESS=(PROTOCOL=TCP)(HOST=host2)(PORT=1521))) (CONNECT_DATA=(SERVICE_NAME=service_name)))" OCI, using a cluster: "jdbc:oracle:oci:@(DESCRIPTION= (ADDRESS=(PROTOCOL=TCP)(HOST=cluster_alias) (PORT=1521)) (CONNECT_DATA=(SERVICE_NAME=service_name)))" Thin-style service name Thin "jdbc:oracle:thin:scott/tiger@//myhost:1521/myservicename" LDAP syntax Thin "jdbc:oracle:thin:@ldap://ldap.example.com:7777/sales,cn=OracleContext,dc=com" Bequeath connection OCI Empty. That is, nothing after @ "jdbc:oracle:oci:scott/tiger/@" TNSNames alias Thin, OCI OracleDataSource ods = new OracleDataSource(); ods.setTNSEntryName("MyTNSAlias");
Created by Dr. Xi on January 07, 2010 23:40:28    Last update: February 09, 2010 03:24:35
This is a utility to generate SQL insert statements for Oracle for one table, or a set of tables. It doesn't cover all possibilities but should be good enough for most cases. import java.io.*; import java.sql.*; import ... To generate insert statements for multiple tables, simply put the table names in a file, one per line, and use the -f switch.
Created by Dr. Xi on January 07, 2010 23:56:00    Last update: January 07, 2010 23:56:00
This is a utility that generates a script to grant privileges for an existing schema for Oracle. import java.io.*; import java.sql.*; pub...
Created by Dr. Xi on January 07, 2010 23:51:44    Last update: January 07, 2010 23:53:57
This is a utility to generate a "create synonym" script for Oracle for an existing schema. import java.io.*; import java.sql.*; pub...
Created by Dr. Xi on January 07, 2010 23:47:36    Last update: January 07, 2010 23:47:36
This is a utility to generate a "create role" script for Oracle for an existing schema. import java.io.*; import java.sql.*; pub...
Created by Dr. Xi on October 18, 2008 02:46:56    Last update: October 18, 2008 02:47:33
There are four pairs of methods in the java.sql.ResultSet class that deal with BLOBs/CLOBs: Reader getCharacterStream(int columnIndex) / Reader getCharacterStream(String columnName) InputStream getBinaryStream(int columnIndex) / InputStream getBinaryStream(String columnName) Blob getBlob(int i) / Blob getBlob(String colName) Clob getClob(int i) / Clob getClob(String colName) Example code: PreparedStatement pstmt = conn.prepareStatemen...
Created by Dr. Xi on September 04, 2008 19:14:06    Last update: September 04, 2008 19:14:22
import java.sql.*; import java.io.*; pub...
Created by Dr. Xi on September 04, 2008 18:56:19    Last update: September 04, 2008 18:56:42
If you keep SQL strings in a file, you probably comment it to make it more readable. But when you feed the SQL to JDBC, you may prefer to clean it up. This is a regex to do that. public class CleanupSql { public static voi...