Thursday, January 28, 2010

JDBC Java Program Using JDBC TYPE 3 Driver

A Sample Java Program Using JDBC TYPE 3 Driver. This driver is called as Network Protocol Pure Java Driver. This driver would only be the option when DB vendor supplied Type II & IV drivers are not available.

Software: www.idssoftware.com


Server:


a) Install IDSServer software


b) d:\IDSServer\IDSS.exe


(The above said .exe runs as system startup service. IDSS.exe is a server socket program which runs on port number 12.)


c) Notice one more dir called


d:\IDSServer\classes>


jdk11drv.jar, jdk13drv.jar, jdk14drv.jar


Client:
a) Client must demand server to download jdk14drv.jar file into client system and the same must be updated in CLASSPATH

[Note: Software installation is not required]


PATH: (only server)


d:\IDSServer


CLASSPATH (server & client)


d:\IDSServer\classes\jdk14drv.jar


Arch:


Driver: ids.driver.IDSDriver


URL: jdbc:ids://abc:12/conn?dsn='oracleSysDSN'


Procedure creation


c:> sqlplus scott/tiger


SQL> cle scr


sql> create or replace procedure emp_sal_proc(eno IN number, sal1 OUT number) IS

BEGIN

SELECT sal INTO sal1 FROM emp WHERE empno=eno;

END;


// Java
Program

// ProcExecTest.java


import java.sql.*;
public class ProcExecTest

{

public static void main(String rags[]) throws Exception

{

Class.forName("ids.driver.IDSDriver");

Connection
con=DriverManager.getConnection
("jdbc:ids://abc:12/conn?dsn
='oracleSysDSN'", "scott", "tiger");
CallableStatement cstmt=con.prepareCall("{call emp_sal_proc(?,?)}");

cstmt.setInt(1, Integer.parseInt(rags[0]));

cstmt.registerOutParameter(2, Types.DOUBLE);

cstmt.execute();

System.out.println(cstmt.getDouble(2));

cstmt.close();

con.close();

}// main()

}// class

Read more...

Wednesday, January 27, 2010

Hibernate Meta Model

The meta model is the model used by Hibernate core to perform its object relational mapping. The model includes information about tables, columns, classes, properties, components, values, collections etc. The API is in org.hibernate.mapping and its main entry point is the Configuration class, the same class that is used to build a session factory.

The model represented by the Configuration class can be build in many ways. The following list the currently supported ones in Hibernate Tools.

  • A Core configuration uses Hibernate Core and supports reading hbm.xml files, requires a hibernate.cfg.xml. Named core in Eclipse and <configuration> in ant.
  • A Annotation configuration uses Hibernate Annotations and supports hbm.xml and annotated classes, requires a hibernate.cfg.xml. Named annotations in Eclipse and <annotationconfiguration> in ant.
  • A JPA configuration uses a Hibernate EntityManager and supports hbm.xml and annotated classes requires that the project has a META-INF/persistence.xml in its classpath. Named JPA in Eclipse and <jpaconfiguration> in ant.
  • A JDBC configuration uses Hibernate Tools reverse engineering and reads its mappings via JDBC metadata + additional reverse engineering files (reveng.xml). Automatically used in Eclipse when doing reverse engineering from JDBC and named <jdbcconfiguration> in ant.
In most projects you will normally use only one of the Core, Annotation or JPA configuration and possibly the JDBC configuration if you are using the reverse engineering facilities of Hibernate Tools. The important thing to note is that no matter which Hibnerate Configuration type you are using Hibernate Tools supports them.

The code generation is done based on the Configuration model no matter which type of configuration have been used to create the meta model, and thus the code generation is independent on the source of the meta model and represented via Exporters.

Read more...
Blog Widget by LinkWithin

JS-Kit Comments

  © Blogger template Newspaper III by Ourblogtemplates.com 2008

Back to TOP