Creating a CLOB in jdbc

I have a PL/SQL stored procedure which accepts a CLOB data type as one of the arguments. This procedure inserts a record into a table which has a column of datatype CLOB.
Using jdbc, my java program creates a CallableStatement to the stored proc. Now I wish to create the CLOB based on a String value and pass it to the stored proc.
This is a snippet of my code.
import java.io.*;
import java.sql.*;
import oracle.jdbc.driver.*;
import oracle.sql.*;
public class TestClob2 {
public static Connection getConnection() throws FPError {
Connection connection = null;
String hostname= "ahost";
String host = "jdbc:oracle:thin:@" + hostname+ ":1521:db";
String user = "user";
try {
DriverManager.registerDriver( new oracle.jdbc.driver.OracleDriver());
connection = DriverManager.getConnection(host, user, user);
} catch ( Exception e ){
System.out.println("could not get connection" + e.toString());
} catch ( Throwable t ){
System.out.println("could not get connection" + t.toString());
} finally {
return connection;
public static void main( String[] args){
Connection con = null;
try {
con = getConnection();
OracleCallableStatement stmt = (OracleCallableStatement) con.prepareCall("{call plsqlStoredProc(? )}");
String message="Test for Clob";
try
oracle.sql.CLOB cl = new oracle.sql.CLOB( (OracleConnection) con);
//byte[] msg = message.getBytes("UTF8");
//CLOB cl = new CLOB( (OracleConnection) con, msg);
if ( cl == null ) System.out.println("clob is null");
long index = cl.getLength();
System.out.println("length is " + l );
int i = cl.putString(index+1, message);
stmt.setCLOB(1, cl);
stmt.executeUpdate();
catch (SQLException excep)
System.out.println(excep.getMessage());
excep.printStackTrace();
//new LogException(excep.getMessage());
} catch (Exception e ) {
System.out.println("caught exception " + e.toString());
e.printStackTrace();
} finally {
try { if (con != null ) con.close(); } catch ( Exception e){ }
I get the following error
caught exception java.lang.NullPointerException:
java.lang.NullPointerException:
at oracle.sql.Datum.getBytes(Datum.java:147)
at oracle.jdbc.driver.OraclePreparedStatement.setCLOB(OraclePreparedStat
ement.java)
at oracle.sql.CLOB.plsql_write(Compiled Code)
at oracle.jdbc.ttc7.TTC7Protocol.lobWrite(TTC7Protocol.java)
at oracle.sql.CLOB.putChars(CLOB.java)
at oracle.sql.CLOB.putString(CLOB.java)
at TestClob3.main(TestClob3.java:38)
Can anybody tell me how I can create a CLOB in jdbc to pass it over to a PL/SQL stored proc.
When I test the stored procedure using a PL/SQL proc ( creating a temporary clob and passing it to the stored proc ) it works fine.
Can somebody point out the mistake in my code. Appreciate it.
Thanks.
null

Hello,
First of i must admit that i am naive to installation softwares. But i can tell u that u can create tables using java and jdbc. I have done it myself. As far as creating database in concerned i haven't tried it out yet. But my gut feeling is that u can create it. I u are interested in having a look at the sample code then here it is.
import java.sql.*;
public class demoddl
public static void main(String[] args) throws SQLException
try
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@10.0.0.8:1521:oraserv","scott","lion");
Statement stmt = con.createStatement();
boolean b = stmt.execute("create table demoddl(a number)");
System.out.println("Boolean
catch(Exception e)
System.out.println("Exception="+e.toString());
}

Similar Messages

  • Problem in creating Oracle CLOB thorough JAVA

    HI,
    I am facing problem in inserting CLOB data through Oracle.
    My code sends exception at below java code line:-
    oracle.sql.CLOB newClob = oracle.sql.CLOB.createTemporary(nativeConnection,false, oracle.sql.CLOB.DURATION_SESSION);
    Exception is:::::
    ===========
    11/08/10 19:12:33 InsertQuery is::::::>>>>INSERT INTO MCREDIT_XML (Inmxml,outmxml,app_id_c,REQUEST_ID,request_date) values (?,?)
    11/08/10 19:12:50 Error In Clob----->oracle.jdbc.internal.OracleConnection oracle.jdbc.OracleConnection.physicalConnectionWithin()
    com.evermind.server.rmi.OrionRemoteException: Transaction was rolled back: java.lang.AbstractMethodError: oracle.jdbc.internal.OracleConnection oracle.jdbc.OracleConnection.physicalConnectionWithin()
    at QdeMain_StatelessSessionBeanWrapper50.processRequest(QdeMain_StatelessSessionBeanWrapper50.java:158)
    at com.nucleus.los.bean.trackinginterface.ejb.DedupeExtBean.onMessageMCredit(DedupeExtBean.java:153)
    at com.nucleus.los.bean.trackinginterface.ejb.DedupeExtBean.onMessage(DedupeExtBean.java:82)
    at com.evermind.server.ejb.MessageDrivenBeanInvocation.run(MessageDrivenBeanInvocation.java:123)
    at com.evermind.server.ejb.MessageDrivenHome.onMessage(MessageDrivenHome.java:745)
    at com.evermind.server.ejb.MessageDrivenHome.run(MessageDrivenHome.java:916)
    at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:186)
    at java.lang.Thread.run(Thread.java:534)
    Nested exception is:
    java.rmi.RemoteException: oracle.jdbc.internal.OracleConnection oracle.jdbc.OracleConnection.physicalConnectionWithin(); nested exception is:
    java.lang.AbstractMethodError: oracle.jdbc.internal.OracleConnection oracle.jdbc.OracleConnection.physicalConnectionWithin()
    at com.evermind.server.ejb.EJBUtils.makeException(EJBUtils.java:941)
    at QdeMain_StatelessSessionBeanWrapper50.processRequest(QdeMain_StatelessSessionBeanWrapper50.java:158)
    at com.nucleus.los.bean.trackinginterface.ejb.DedupeExtBean.onMessageMCredit(DedupeExtBean.java:153)
    at com.nucleus.los.bean.trackinginterface.ejb.DedupeExtBean.onMessage(DedupeExtBean.java:82)
    at com.evermind.server.ejb.MessageDrivenBeanInvocation.run(MessageDrivenBeanInvocation.java:123)
    at com.evermind.server.ejb.MessageDrivenHome.onMessage(MessageDrivenHome.java:745)
    at com.evermind.server.ejb.MessageDrivenHome.run(MessageDrivenHome.java:916)
    at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:186)
    at java.lang.Thread.run(Thread.java:534)
    Caused by: java.lang.AbstractMethodError: oracle.jdbc.internal.OracleConnection oracle.jdbc.OracleConnection.physicalConnectionWithin()
    at oracle.sql.CLOB.createTemporary(CLOB.java:684)
    at oracle.sql.CLOB.createTemporary(CLOB.java:651)
    at com.nucleus.los.dao.daofactory.OracleDAOFactory.executePreparedUpdateClob(OracleDAOFactory.java:2352)
    at com.nucleus.los.bean.application.qde.MCreditInterfaceBean.processRequest(MCreditInterfaceBean.java:171)
    at com.nucleus.los.bean.application.qde.ejb.QdeMainBean.processRequest(QdeMainBean.java:84)
    at QdeMain_StatelessSessionBeanWrapper50.processRequest(QdeMain_StatelessSessionBeanWrapper50.java:101)
    ... 7 more

    AbstractMethodErrorThat occurs when something wants to call a method which does not exist.
    For example if something expects JDBC 4 but the jdbc driver that is being used is for JDBC 2.

  • How to create db conn for JDBC-ODBC Bridge for MS Access in ADF APP?

    Sir,
    How to create db conn for JDBC-ODBC Bridge for MS Access in ADF APP?
    Regards

    Hello Every Body!
    I succeeded in getting connect to the ms access database in adf application in jdeveloper as below:
    First in control panel to to admin tools and  go to data source(odbc) and create system dsn as bellow pic
    Then go to jdeveloper resources ide conn and then database and new database conn and then select jdbc-odbc briddge and then give custom jdbc url as bellow pic
    Cheers
    tanvir

  • Create java procedure using jdbc

    Hi,
    I am trying to create java procedure using jdbc connection, I am using Oracle 11.2. When I create the procedure using sqlplus it works fine. Using jdbcit fails; code sniplet below:
                   ddl =
                   "create or replace java source named \"UTLCMD\" as \r\n"+
                   "import java.lang.Runtime; \r\n"+
                   "public class execHostCommand \r\n"+
                   "{ \r\n"+
                   "public static void execute (String command) \r\n"+
                   " throws java.io.IOException \r\n"+
                   " { \r\n"+
                   " Runtime rt = java.lang.Runtime.getRuntime(); \r\n"+
                   " rt.exec(command); \r\n"+
                   " } \r\n"+
                   statement = conn.createStatement();
                   statement.executeUpdate(ddl);
    I am getting this error:
    2013-01-26 12:45:31.835 UTC: ERROR: Exception "java.sql.SQLException: ORA-29536: badly formed source: Encountered "ublic" at line 3, column 1.
    Was expecting one of:
    "extends" ...
    "implements" ...
    "<" ...
    ". Stack dump:

    Hi,
    We can load java class using blob column, for example :
    create or replace and compile java class using blob select code from java_code;If class is OK, but resolution of referenced names to other classes failed, statement.execute() will not show any error and we need to 'select from user_errors' view for errors. How can we got the required object name for loaded class?

  • Oracle database open cursor created by clob.getCharacterStream()

    I cannot close open cursor created by clob.getCharacterStream();
    I use the following code. Please note that I close the Reader Stream.
    Since my database connection is pooled I cannot close the connection to close the cursor. SQL_TEXT field in v$open_cursor shows "table_4_200_1862_0_0_0" or some thing like that.
    Thanks in advance for any reply.
    public static String readClob( Clob clob )
    StringBuffer bufCLOB = new StringBuffer();
    int nbytes = 0;
    char[] buffer = new char[ 32768 ];
    try
    java.io.Reader clobReader = clob.getCharacterStream();
    int len = 0;
    while( ( len = clobReader.read( buffer ) ) != -1 ){
    bufCLOB.append( buffer, 0, len );
    clobReader.close();
    catch( Exception ex )
    ex.printStackTrace();
    return bufCLOB.toString();
    }

    I found the reply from somewhere. It seems implecit open cursors donot count to maximum allowed one. While updaint clob fields oracle opens implecit open cursors.

  • HELP:Problem in creating a temporary CLOB using JDBC connection pooling

    Hi All,
    i am inserting a large xml document in an xml type column by creating a temporary clob of this document
    tempClob = CLOB.createTemporary(conn, true, CLOB.DURATION_SESSION);
    I am not having any success getting the following statement working using a JDBC connection pool rather than a hard coded URL connection
    it works with:
    "jdbc:oracle:thin:@server:port:dbname" connection
    Does NOT work with:
    datasource.getConnection()
    Does any one know how to successfully get this to work?
    urgently plz........

    Hi Dharmi
    Here is a quote of Dafna's post in [another thread in this forum|Re: Copy VC controls]
    CE7.1.1 will be released at September 2008 for ramp-up customers.
    There are many improvements and new capabilities in the new release of Visual Composer for CE7.1.1. Among the new features you can find:
    The missing features from Visual Composer 7.0 (Html view, portal Eventing support (EPCM), JDBC, Undo/Redo, and more..)
    Many layout & modeling improvements
    Additional ALV table functionality - export to Excel, switch to chart, configure ALV behavior at design time
    Integration of Visual Composer in Eclipse - additional entry point to the Visual Composer models from the NWDS. This integration provides the option to add a WD component (in case of missing functionality in Visual Composer), as a black box component to the Visual Composer model. Right-clicking the component will open the Web Dynpro perspective for creating/modifying the component.
    Regards,
       Shai

  • Problem using CLOB in JDBC (NewLOBAPISample)

    I've just tried to run the JDBC NewLOBAPISample, and everything works fine until I try to insert or update on the CLOB column using any characters other than base ASCII. For example, if I attempt to insert the String "$100", it works just fine, but "£100" results in:
    java.sql.SQLException: No more data to read from socket
    I've experimented with this issue with a much smaller test case of my own, and I've been able to narrow down the problem, as I've outlined below. In all cases, PreparedStatement is used for executing.
    Let's say we have a table named "Test" with one CLOB column named "text".
    The original "official" API for inserting a CLOB using the latest 1.4 JDBC Oracle thin driver is:
    // first insert an "empty CLOB"
    PreparedStatement ps;
    ps = con.prepareStatement("INSERT INTO Test (text) VALUES (empty_clob())");
    ps.executeUpdate();
    // then select the empty CLOB
    con.setAutoCommit(false);
    ps = con.prepareStatement("SELECT text FROM Test FOR UPDATE");
    ResultSet rs = ps.executeQuery();
    rs.next();
    CLOB clob = ((OracleResultSet)rs).getCLOB(1);
    // now write to the CLOB
    Writer out = clob.getCharacterOutputStream();
    out.write(myLongText);
    out.close();
    // we're done
    connection.commit();
    The method that is advertised in NewLOBAPISample, and which I've also seen on the Java Developer Forum, is outlined here:
    // first, create statement to insert
    PreparedStatement ps;
    ps = con.prepareStatement("INSERT INTO Test (text) VALUES (?)");
    // create a temporary CLOB and write to it
    CLOB clob = CLOB.createTemporary(con, true, CLOB.DURATION_SESSION);
    Writer out = clob.getCharacterOutputStream();
    out.write(myLongText);
    // set the CLOB on the PreparedStatement and execute
    ps.setClob(1, clob);
    ps.executeUpdate();
    Now, in the above two cases, if "myLongText" has any characters in it besides standard alpha-numerics, the latter approach will fail, although the former (original) approach will still work. In my case, I need to save Danish characters in the CLOB data. (I can't type these characters in this message, as for some reason they are being converted to "æ å ø" during posting, instead of the letters I've typed on my keyboard.)
    Here is a stack trace when I try the createTemporary approach with a short String that contains one or more non-standard characters:
    java.io.IOException: No more data to read from socket
         at oracle.jdbc.dbaccess.DBError.SQLToIOException(DBError.java:716)
         at oracle.jdbc.driver.OracleClobWriter.flushBuffer(OracleClobWriter.java:270)
         at oracle.jdbc.driver.OracleClobWriter.close(OracleClobWriter.java:232)
    Here's the strack trace when the insert String contains only ONE character that is non-standard:
    java.sql.SQLException: No more data to read from socket
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
         at oracle.jdbc.dbaccess.DBError.check_error(DBError.java:1160)
         at oracle.jdbc.ttc7.MAREngine.unmarshalUB1(MAREngine.java:963)
         at oracle.jdbc.ttc7.MAREngine.unmarshalSB1(MAREngine.java:893)
         at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:369)
         at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1891)
         at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1093)
         at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2047)
         at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1940)
         at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2709)
         at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:589)
    Any help with this would be MUCH appreciated.
    Thanks,
    David Karlton

    hi David,
    i tried inserting non-alphanumeric chars but still it goes thru fine.
    here is what i did,
    create table testlob ( id number(5),lobcol clob);
    LobInJava.java
    import java.sql.*;
    import oracle.jdbc.*;
    import oracle.sql.*;
    class LobInJava
    public static void main(String args[]) throws Exception
    DriverManager.registerDriver(new
    oracle.jdbc.driver.OracleDriver());
    Connection conn = DriverManager.getConnection
    ("jdbc:oracle:thin:@host:1522:ora9idb", "scott", "tiger");
    StringBuffer myLongText = new StringBuffer("nm{H$ñVmZ".length() * 10 );
    for(int i=0 ;i < 1000 ;i++ )
    myLongText.append("nm{H$ñVmZ");
    System.out.println( myLongText.length());
    PreparedStatement ps;
    ps = conn.prepareStatement("INSERT INTO Testlob (id,lobcol) VALUES (2,empty_clob())");
    ps.executeUpdate();
    // then select the empty CLOB
    conn.setAutoCommit(false);
    ps = conn.prepareStatement("SELECT lobcol FROM Testlob where id=2 FOR UPDATE");
    ResultSet rs = ps.executeQuery();
    rs.next();
    CLOB clob = ((OracleResultSet)rs).getCLOB(1);
    // now write to the CLOB
    java.io.Writer out = clob.getCharacterOutputStream();
    out.write(myLongText.toString());
    out.close();
    // we're done
    conn.commit();
    ps.close();
    // first, create statement to insert
    PreparedStatement ps;
    ps = conn.prepareStatement("INSERT INTO Testlob (id,lobcol) VALUES (1,?)");
    // create a temporary CLOB and write to it
    CLOB clob = CLOB.createTemporary(conn, true, CLOB.DURATION_SESSION);
    java.io.Writer out = clob.getCharacterOutputStream();
    out.write(myLongText.toString());
    out.close();
    // set the CLOB on the PreparedStatement and execute
    ps.setClob(1, clob);
    ps.executeUpdate();
    ps.close();
    conn.close();
    i am using jdk 1.3 and Oracle9i v9.0.1
    Regards
    Elango.

  • How to handle CREATE or INSERT in JDBC

    Hi experts,
    i'm designing my idoc to JDBC scenario, but is it possible when the message arrives into the database to CREATE a table if it does not exist or to INSERT data if the table already exists?
    Thanks in advance,
    Regards.
    Jamal

    Hi,
    check some links on JDBC.
    FILE to JDBC Adapter using SAP XI 3.0 - File to JDBC
    JDBC - http://help.sap.com/saphelp_nw2004s/helpdata/en/64/ce4e886334ec4ea7c2712e11cc567c/content.htm
    multiple tables with JDBC - http://help.sap.com/saphelp_nw04/helpdata/en/2e/96fd3f2d14e869e10000000a155106/content.htm
    JDBC Response Send RFC to SAP XI – Asynchronous
    http://help.sap.com/saphelp_nw04/helpdata/en/7e/5df96381ec72468a00815dd80f8b63/content.htm
    RDBMS system integration using XI 3.0 JDBC Sender/Receiver adapter
    Regards,
    Phani

  • ORA-03115 Error using CLOB with JDBC

    When I try to access CLOB field data with JDBC driver, I gets following error:
    ORA-03115: unsupported network datatype or representation.
    I am using JDBC 8.1.6(Thin), Oracle 8.0.5
    on Linux OS.
    what's the problem ?
    Thank you for any help.
    Taesoo.
    null

    if it is a bug, then its better to upgrade the database to 10.2.0.4. it is the stable verion in 10g.

  • Some times on Tomcat start up it creates SSL error while JDBC connection to SQL server

    We are using Apache Tomcat 6 and SQL server 2008 on production. In the application in ServletContextListner we make DB connection to read some property from DB. When we restart the Tomcat 6.0 in that case sometimes it does not gets DB connection till 5 to
    10 minutes. It does not happen every time. We are using JNDI for getting the Datasource objectand using SQL JDBC 3.0 driver. We get following error in log
    org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: "Connection reset by peer: socket write error".)
    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1225)
    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
    at com.rightwave.util.RWDBConnectionManager.getConnection(RWDBConnectionManager.java:145)
    at com.rightwave.util.RWDataBaseDAO.executeQuery(RWDataBaseDAO.java:306)
    at com.rightwave.util.RWDataBaseDAO.executeQuery(RWDataBaseDAO.java:289)
    at com.rightwave.admin.RWApplicationContext.setMConfigurationProperties(RWApplicationContext.java:226)
    at com.rightwave.admin.RWAdminApplicationContext.initialize(RWAdminApplicationContext.java:85)
    at com.rightwave.admin.RWServletContextListener.contextInitialized(RWServletContextListener.java:186)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
    at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:627)
    at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:553)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:488)
    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
    at org.apache.catalina.core.StandardService.start(StandardService.java:516)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
    Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: "Connection reset by peer: socket write error".
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:1368)
    at com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1412)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1058)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:833)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:716)
    at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:841)
    at org.apache.tomcat.dbcp.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)
    at org.apache.tomcat.dbcp.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:294)
    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1247)
    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1221)
    ... 31 more
    Caused by: java.io.IOException: Connection reset by peer: socket write error
    at com.microsoft.sqlserver.jdbc.TDSChannel$SSLHandshakeInputStream.ensureSSLPayload(IOBuffer.java:500)
    at com.microsoft.sqlserver.jdbc.TDSChannel$SSLHandshakeInputStream.readInternal(IOBuffer.java:570)
    at com.microsoft.sqlserver.jdbc.TDSChannel$SSLHandshakeInputStream.read(IOBuffer.java:562)
    at com.microsoft.sqlserver.jdbc.TDSChannel$ProxyInputStream.readInternal(IOBuffer.java:757)
    at com.microsoft.sqlserver.jdbc.TDSChannel$ProxyInputStream.read(IOBuffer.java:745)
    at com.sun.net.ssl.internal.ssl.InputRecord.readFully(Unknown Source)
    at com.sun.net.ssl.internal.ssl.InputRecord.read(Unknown Source)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(Unknown Source)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(Unknown Source)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(Unknown Source)
    at com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1379)
    ... 39 more
    Urgent help will be appreciated. 

    So, you've got a network error.. Check your physical layer.

  • Error when create XMLType object with JDBC connection

    Hello, I try to get an XMLType object with JDBC, but it doesn't work. Can somebody help me?
    My code is :
    Class.forName("oracle.jdbc.driver.OracleDriver");
    Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@"+"a02w03:1521:PROJET", "scott", "tiger");
    OraclePreparedStatement stmt = (OraclePreparedStatement) conn.prepareStatement("select xmldoc from cv_col");
    ResultSet rset = stmt.executeQuery();
    OracleResultSet orset = (OracleResultSet) rset;
    while(orset.next())
    OPAQUE o = orset.getOPAQUE(1);
    System.out.println(o.getSQLTypeName());
    XMLType poxml = XMLType.createXML(o);
    My database table:
    CREATE TABLE cv_col (
    XMLDoc xmltype
    Execution: The SQL type name "SYS.XMLTYPE" is write and then I obtain the error:
    Exception in thread main
    java.lang.NoSuchMethodError: java.lang.String oracle.jdbc.internal.OracleConnection.getProtocolType()
         at oracle.xdb.XMLType.initConn(XMLType.java:2072)
         at oracle.xdb.XMLType.<init>(XMLType.java:903)
         at oracle.xdb.XMLType.createXML(XMLType.java:493)
         at Prog.main(Prog.java:26)
    Process exited with exit code 1.
    Thank you, very much!

    What platform are you using for the database, what are you running your code on.
    Which database version are you working with.. What is your class path. What version of JDBC and OCI are in the client environment, eg what are CLASSPATH and PATH / LD_LIBRARY_PATH settings. Have you tested your code using a simple IDE like Oracle's JDeveloper or run it from directly from the command line.

  • Creating a read-only JDBC interface?

    I'm facing a challenge providing ODBC for an in-memory Java application. There are commercial frameworks such as Simba and DataDirect but both involve extensive licensing and are too elaborate (given only read-only capability with basic single table querying required).
    Another option I'm investigating is to use an ODBC-JDBC bridge driver (such as provided by EasySoft) in combination with a bespoke JDBC connector. The question is, how complex is it to implement a SELECT-only JDBC driver to interface directly with a Java app? (And as extension, are there any libraries that can assisting in creating a JDBC driver?)
    Any ideas much appreciated,
    Lance

    LanceJ wrote:
    I'm facing a challenge providing ODBC for an in-memory Java application. There are commercial frameworks such as Simba and DataDirect but both involve extensive licensing and are too elaborate (given only read-only capability with basic single table querying required).
    As stated that is not possible.
    Read the following and then restate the question
    [http://forums.sun.com/thread.jspa?threadID=211735&start=2&forumID=48]
    Another option I'm investigating is to use an ODBC-JDBC bridge driver (such as provided by EasySoft) in combination with a bespoke JDBC connector. The question is, how complex is it to implement a SELECT-only JDBC driver to interface directly with a Java app? (And as extension, are there any libraries that can assisting in creating a JDBC driver?)That doesn't make sense.
    The bridge and any "ODBC" interface is going to interact with the ODBC shell and a ODBC driver (nothing to do with java.) You can't create a ODBC driver without creating a ODBC driver. Which would seem obvious.
    If you want to create a JDBC driver - which is not the same as an ODBC driver then you must implement the interfaces. Simple as that. That however requires that you must have some way to actually access the database.

  • 9i CLOBs vs JDBC -- contradiction and frustration

    Oracle's various "what's new" whitepapers for 9i all joyfully proclaim its new ability to handle CLOB fields using SQL semantics. However, I've spent most of the day getting increasingly frustrated, because it's increasingly beginning to look like they should have followed it with a big, bold, red warning that it doesn't apply if you're using JDBC.
    What's the real story about 9i and CLOBs? Does 9i REALLY support treating them like big, ersatz VARCHAR2 objects (at least, for things that are too big for VARCHAR2, but still pretty small)? And if it does, what does taking advantage of this great new convenience using JDBC require (besides dropping ojdbc14.jar into the classpath)?
    So far, I've seen at least one post here declaring that Statement.setString(int index, String value) is still limited to 4000 characters. If that's true, is it a JDBC-imposed limit, or an Oracle-imposed limit? And if it's Oracle imposed, doesn't that flat-out contradict their own documentation? I guess I could live with limits on setString(), but if the same restriction exists with getString(), I'm going to go outside and shout vile, anti-Oracle obscenities at the traffic for a while... ;-)
    Seriously, though... is the general lack of working examples of newly-convenient CLOB access via JDBC just because few people are aware of it yet and keep doing it the old way, or are the new SQL Semantics capabilities utterly meaningless as far as practical get/set column access from JDBC is concerned, and we're still stuck having to handle our own stream and buffer semantics just to read 6,000 character long fields?

    how I did clobs (before new stuff I think, did early this year) as a get around for CMP. having to use oracle.sql.CLOB is a drawback but databases shouldnt change too often.
    import javax.sql.*;
    import java.sql.*;
    import java.io.*;
    import oracle.sql.CLOB;
    setting::
    Connection c = null; PreparedStatement p = null; ResultSet r = null;
    try {
    ServiceLocator sl = ServiceLocator.getInstance();
    DataSource ds = sl.getDataSource(dsName);
    c = ds.getConnection();
    c.setAutoCommit(false);
    PreparedStatement ps = c.prepareStatement("GET myCLOB from mytable where pid=?");
    ps.setLong(1,aPK.longValue());
    r = ps.executeQuery();
    if (r.next()) {
    CLOB oraclob = (CLOB)r.getClob("myCLOB");
    oraclob.trim(0);
    Writer w = oraclob.getCharacterOutputStream();
    w.write(clob);
    w.flush();
    w.close();
    c.commit();
    c.setAutoCommit(true);
    r.close();
    ps.close();
    c.close();
    catch (Exception e)
    e.printStackTrace(System.out);
    throw new Exception(e.getMessage());
    and getting::
    Connection c = null; PreparedStatement p = null; ResultSet r = null;
    String ret = "Empty";
    try {     
    ServiceLocator sl = ServiceLocator.getInstance();
    DataSource ds = sl.getDataSource(dsName);
    c = ds.getConnection();
    p = c.prepareStatement(stmt);
    p.setLong(1,aPK.longValue());
    r = p.executeQuery();
    if (r.next())
    Clob clob = r.getClob("myCLOB");
    ret = clob.getSubString(1L,Integer.parseInt(Long.toString(clob.length())));
    r.close(); p.close(); c.close();
    catch (NullPointerException npe) {}
    catch (Exception e)
    throw new Exception(e.getMessage());

  • Problem creating SQL commands in JDBC

    I want to send the following seemingly very simple SQL statements to the mysql server via JDBC inside a servlet:
    querry1: SELECT * FROM japeng_math WHERE (kanji='userInput' OR kana='userInput')
    querry2: SELECT * FROM majors WHERE major='majorcode'     
    userInput and majorcode are variables of type String. They are assigned values before using in the SQL.
    I coded the commands as follows:
    querry1 = "select * from japeng_math where (kanji=" + "'" userInput "'" + "or kana=" + "'" userInput "'" + ")" ;
    System.out.println("querry 1: " + querry1);
    querry2 = "select * from majors where major=" + "'" + majorcode + "'";
    System.out.println("querry 2: " + querry2);
    I can't find what is going wrong here, but I'm not getting the desired strings for querry1 and querry2.
    I found that error in querry string occurs only when two-byte Japanese characters (which is the commone case) are input.
    Here is the output at console:
    1. when a two-byte Japanese character was input in the form field
    querry 1: select * from japeng_math where (kanji='���a'or kana='���a')
    'uerry 2: select * from majors where major='geom
    (There is an apostrophe in place of q of querry. And also major='geom. But the expected value should have been : major='geom')
    2. when single-byte (hankaku) Japanese character was input
    querry 1: select * from japeng_math where (kanji='����'or kana='����')
    querry 2: select * from majors where major='geom'
    (both OK)
    3. when English was input, both OK.
    I'm stuck. Please help. How can I make it work seamlessly, without worrying what type of charcters are input?
    By the way, my database & server setting are in Shift-JIS. I've also converted the input string to Shift-JIS in the program
    before using it.
    Thank you very much.

    >
    I'm stuck. Please help. How can I make it work
    seamlessly, without worrying what type of charcters
    are input?Characters in java are in unicode.
    When you display characters, such as when System.out is used, the unicode is converted into something else.
    Similarily when you go through the JDBC interface they are converted to something else.
    And depending on the source of the characters they might not be unicode to start with.
    So the first step is to determine that the input strings actually contain the characters that you expect. The only way to do that is to print each character as an integer (hex format) and then look it up in a unicode chart to determine that it is the correct character. Until you do this you there is no point in trying anything else.
    Once you determine this then the next step is to use a PreparedStatement to create the SQL. This might work. Or it might not. You should read the following thread including the links posted there ....
    http://forum.java.sun.com/thread.jsp?forum=48&thread=407345

  • PL Sql create/replace proc via jdbc, possible, wl7.0sp1?

    Hi,
    Sorry for this basic question, I've looked in the archives and can't find an answer.
    I need to dynamically create users on an oracle 8i db and run a script to create
    a standard set of tables for them from Weblogic server jdbc.
    The problem I have is that the script not only creates some tables but also populates
    them with a procedure (example below).
    My question is simply:
    Is this possible to do using JDBC, or do I need to "Runtime.getRuntime().exec..."
    the PLSQL exe under windows and write the script to it.
    Thanks
    David
    Script:
    CREATE OR REPLACE PROCEDURE populate_d_time IS
    timeID d_time.time_id%TYPE;
    timeOfDay d_time.time_of_day%TYPE;
    hourOfDay d_time.hour_of_day%TYPE;
    minuteOfHour d_time.minute_of_hour%TYPE;
    secondOfMinute d_time.second_of_minute%TYPE;
    BEGIN
    --initialise
    timeID := 1;
    timeOfDay := TO_DATE('00:00:00', 'HH24:MI:SS');
    --start looping, stop at ending time
    WHILE (timeOfDay <= TO_DATE('23:59:59', 'HH24:MI:SS')) LOOP
    --get information about the data
    hourOfDay := TO_CHAR(timeOfDay, 'HH24');
    minuteOfHour := TO_CHAR(timeOfDay, 'MI');
    secondOfMinute := TO_CHAR(timeOfDay, 'SS');
    INSERT INTO d_time
    VALUES (timeID, hourOfDay, minuteOfHour, secondOfMinute, timeOfDay);
    --increment
    timeID := timeID + 1;
    timeOfDay := timeOfDay + (1/86400); -- Add one second
    END LOOP;
    END;

    Thanks, but my question was can you create a plsql statement from java.
    I think you can only create them in sqlplus, so I assume therefore that I have
    to shell sqlplus.exe from java and write the script to it's inputstream.
    -unless anyone knows a way of doing this from a connection object which would
    be more elegant.
    Thanks
    DB
    Mitesh Patel <[email protected]> wrote:
    If you already have stored procedure created, you can use callablestatement
    to execute
    it. Look for examples on callablestatement. You can do it sure.
    Mitesh
    David Bisbal wrote:
    Hi,
    Sorry for this basic question, I've looked in the archives and can'tfind an answer.
    I need to dynamically create users on an oracle 8i db and run a scriptto create
    a standard set of tables for them from Weblogic server jdbc.
    The problem I have is that the script not only creates some tablesbut also populates
    them with a procedure (example below).
    My question is simply:
    Is this possible to do using JDBC, or do I need to "Runtime.getRuntime().exec..."
    the PLSQL exe under windows and write the script to it.
    Thanks
    David
    Script:
    CREATE OR REPLACE PROCEDURE populate_d_time IS
    timeID d_time.time_id%TYPE;
    timeOfDay d_time.time_of_day%TYPE;
    hourOfDay d_time.hour_of_day%TYPE;
    minuteOfHour d_time.minute_of_hour%TYPE;
    secondOfMinute d_time.second_of_minute%TYPE;
    BEGIN
    --initialise
    timeID := 1;
    timeOfDay := TO_DATE('00:00:00', 'HH24:MI:SS');
    --start looping, stop at ending time
    WHILE (timeOfDay <= TO_DATE('23:59:59', 'HH24:MI:SS')) LOOP
    --get information about the data
    hourOfDay := TO_CHAR(timeOfDay, 'HH24');
    minuteOfHour := TO_CHAR(timeOfDay, 'MI');
    secondOfMinute := TO_CHAR(timeOfDay, 'SS');
    INSERT INTO d_time
    VALUES (timeID, hourOfDay, minuteOfHour, secondOfMinute, timeOfDay);
    --increment
    timeID := timeID + 1;
    timeOfDay := timeOfDay + (1/86400); -- Add one second
    END LOOP;
    END;

Maybe you are looking for

  • How do I use AirPort Extreme to extend my wifi network - have BT HomeHub 5

    AirPort Extreme is plugged into my HomeHub 5 and I have set it up as extending a network using the Airport Utility, but it isn't finding the network - the light is orange   Please can someone help me. Thanks Joanna

  • ITunes 7 bug for Macs?

    I own a power book and I just updated to iTunes7 and is constantly asking me to update my iPod as well. At the moment I can't do anything with my iPod because the moment I chose a category it quits iTunes. My guess is that the new program is stubborn

  • Events in smart forms

    Hi abapers please guide me about events in tables in smart forms Madhu

  • Limited account users not able to access oracle 9.2 database

    I have installed oracle 9.2 database on windows server 2003 enterprise, I am having 35 users that login through terminal server to use a application developed in VB6 and uses oracle database, Now if I put all users in administrator group of 2003 ever

  • Photoshop CS5 on a 32 bit PC

    Isn't it possible to install the Photoshop CS5 on a computer running a 32 bit Windows 7?