Java.sql.Types.??????

I know clob columns in an oracle database are java.sql.Types.CLOB. What are long raw columns defined as java.sql.Types.???
Thanks in advance,
kmw

Hi ,
Long has no correspondng type in Oracle.sql.Types.So u can access it using the getOBject and setObject.Why do u need to defing the long ?Is it for use i the getter and setter methods of ResultSet or Statements.If so , u have to use streaming and so there is really no need to worry abt the type definition as u are defaulting to an AsciiStream.
Hope it helps.

Similar Messages

  • Java.sql.types and oracletypes

    There appear to be difference in the way the constants are mapped in java.sql.types vs oracletypes(). For example date is '91' in oracletypes and '93' in java.sql.types. The DatabaseMetaData.getColumns() function reports data_type as a java.sql.type. Is there any mapping available from one to the other.
    Thanks

    Erm,
    One way to find out, I reckon.
    Good Luck,
    Avi.

  • Create table dinamically using java sql types?

    Hi! I've an application that reads an XML file. This file contains de definitions of some tables, using java sql types. For example:
    <dbtable>
      <dbtablename>Name of table</dbtablename>
      <dbtablefield>
        <name>Name of table field</name>
        <type>java.sql.Types.VARCHAR</type>
        <length>10</lenght>
        <canNull>0</canNull>
        <isPK>1</isPK>
      </dbtablefield>
    </dbtable>That's a little example of one table, with one field. Is a java.sql.Types.VARCHAR (or is equivalent in int), which has a size of 10, it cannot be null and is a primary key for the table.
    Now, the lenght, null, and primary keys are not problem at all. What I want to know, is how do I create de table using the java.sql.Types. I mean, I don't want to hard code:
    String s = "CREATE TABLE name (COLUMN VARCHAR(10)...";Instead, I want to use some "wild cards", as are used in PreparedStatement. The idea of this is that no matter what DB I'm using, I must always be capable of creating the tables not worrying for the DB. I mean, I must be able to create the table in Oracle, SQL Server, DB2, etc., using the same XML and the same java class.
    Something like:
    String s = "CREATE TABLE name (COLUMN ? (10)...";
    someobject.setObject(1,java.sql.Types.VARCHAR);
    someobject.execute(); //create tableIs this possible? Or do I have to make a map for each DB?
    Thanks a lot for your help! Dukes available!

    you can provide some fields at runtime..
    for example
    "CREATE TABLE name (COLUMN" + arg[1] +"(10)..."
    here arg is the string array passed into the main.

  • Name of an int ( e.g. java.sql.Types )

    I have the sql.Types code as an int number and want to display the name. Is there a straightforward method or do I have to search it in a loop like here ?
    String getName(int i) {
    for (Field f: java.sql.Types.class.getFields()) {
         if (f.getType().equals(int.class)) {
              if (f.getInt(f.getType()) == i) {
              System.out.println( i + " = "+f.getName() );
              // e.g.               8 = DOUBLE
              return f.getName();
    }This question is not specific to java.sql.Types I guess (that's why I post here).
    A dedicated hint for sql is appreciated as well, however ;)

    Seems the loop is required and it works (in no time, there aren't too many Fields)
         if (f.getInt(f.getType()) == i) {Having a closer look, I do not understand the inner f.getType() , however.
    f.getInt() requires an object, but anything, including null, works ?!
    Any hint, or link where to learn about java.lang.reflect.Field, please ?

  • SetNull(2, java.sql.Types.DATE);

    If I use setNull(1, java.sql.Types.DATE); function, it will insert null on my table's column.
    I want to select the date from another table and insert into my table's column, what should I do?
    I am sure I cannot call setNull(1,java.sql.Types.DATE), it will insert NULL in my column.
    Thanks in advance.

    Hi,
    I think you will be better of in asking ths question in Java forum or Oracle Developer forum.
    Regards

  • Java.sql.Types.RAW

    I know you can map a LONG RAW sql type to the java class oracle.sql.RAW when wrapping the java code in your pl/sql wrapper. The problem I am having is that within my java code I am returning result set and using reslutSetMetaData to determine if the column is a varchar or clob with a switch statment and a case comparison using java.sql.Types.whatever sql type i am looking for. I am running into a problem when trying to write a case statement for long raw columns. What would be the statement to use for this. Below is an example of the code.
    int type = rsmd.getColumnType(1);
    switch (type) {
    case java.sql.Types.CLOB:
    code to execute when CLOB type
    break;
    case java.sql.Types.Raw:
    code to execute when LONG RAW type
    break;
    Thanks in advance,
    Kevin
    null

    user1330140 wrote:
    ...the return type which is defined inside DBMS_XDB_VERSION package
    I think there are some threads somewhere that points to Oracle documentation somewhere that says that is not possible with JDBC.
    I could certainly be mistaken however.
    If I am not mistaken then you would need to
    1. Wrap the call to that in another proc.
    2. That proc extracts the result into something that is visible in the jdbc driver.

  • Java.sql.Types.CLOB not returned

    When I run the following on an oracle 8.1.7 server using thin/OCI driver on a table with a CLOB column,
    DatabaseMetaData dbmd = conn.getMetaData();
    ResultSet rs = dbmd.getColumns( null, null, tableName, "%" );
    while (rs.next()){
    int colType = (int)rs.getShort(5);
    I dont get java.sql.Types.CLOB returned in colType, instead I get java.sql.Types.OTHER.
    However, after a query on the same table, the result set metadata.getColumnType() returns java.sql.Types.CLOB.
    Any ideas?
    Thanks in advance

    You can't do that. You can't do it in SQL either: there's no way to call a stored procedure without providing parameters of a specific type.
    There are two things you can do, however: one is to declare the parameter as VARCHAR and hope it's not a BLOB or something that the db will not automatically convert to VARCHAR and the other is to do a SELECT in the procedure you are calling instead of returning the value as an output parameter. The second option is better in that you can then use ResultSet.getObject() from Java and obtain the correct object type, not a String you might need to parse afterwards.
    Alin.

  • Java.sql.Types.BOOLEAN in 9i

    I am trying to figure out what data type i need to set on columns in 9i that will represent java.sql.Types.BOOLEAN data. The docs that i have read around the web say to use a "Byte" type but this is not in the list on my server; in MS SQL2000 i use the "Bit" type and it works great.. is there something simlar in Oracle?

    Hi ,
    Long has no correspondng type in Oracle.sql.Types.So u can access it using the getOBject and setObject.Why do u need to defing the long ?Is it for use i the getter and setter methods of ResultSet or Statements.If so , u have to use streaming and so there is really no need to worry abt the type definition as u are defaulting to an AsciiStream.
    Hope it helps.

  • If DB Column java.sql.Types=CHAR = Workshop autogen EJB CMP Filed=Boolean

    Hi everybody<br>
    <p class="MsoNormal"><span lang="EN-US">When a user automatically
    creates/generates an Entity Bean via BEA Workshop EJB Project option: ‘<b>new
    Entity bean from database table</b>’ and DB Table Column is of type <b>CHAR</b>,
    Workshop creates a <b>@ejbgen:cmp-field</b> of Java type <b>Boolean</b>, NOT of
    <b>Character</b>!</span></p>
    <p class="MsoNormal"><span lang="EN-US">I completely agree that the developer
    must be acquainted with the Data Base and DB Tables as well and he can manually
    correct </span><span lang="EN-US" style="font-size: 10.0pt">SET & GET</span><span lang="EN-US">
    Boolean to Character in EJB source code view or he’ll receive an error if he
    tries to <b>set<i>FieldName</i></b><i>(String/Character) </i>in <b>ejb</b>
    methods.</span></p>
    <p class="MsoNormal"><span lang="EN-US">But suppose that a developer has
    urgently received an order to build an EJB Project for a thousand of DB Tables
    and he hasn’t been acquainted with all of them. He has created the EJBs via <b>
    ‘new -> Entity bean from database table’. </b>He has created some EJB Finders,
    for example a finder:  <b>ejbgen:finder Collection find<i>All</i>()</b>.
    (<i>Suppose he hasn’t used <b>group-name</b> finder property</i>)</span></p>
    <p class="MsoNormal"><span lang="EN-US">He has invoked <b>find<i>All</i>()</b>
    method and depends on the JDBC Driver used, he will receive an </span>
    <span lang="EN-US" style="font-size: 10.0pt">ERROR</span><span lang="EN-US">,
    printed within the Server start console <b>at least</b> OR the result after <b>
    get<i>FieldName</i></b>() will be '<b>false</b>', not an expected <i><b>char</b></i>
    symbol.</span></p>
    <p class="MsoNormal"><b><span lang="EN-US">Anxious conclusion: </span></b></p>
    <p class="MsoNormal"><span lang="EN-US">If<b>  </b>DB Column<b>  java.sql.Types
    = </b></span><span lang="EN-US" style="font-size: 10.0pt"><b>CHAR</b>    </span><span lang="EN-US">then</span><span lang="EN-US" style="font-size: 10.0pt">  
    </span><span lang="EN-US"><b>getJavaObjectType = Boolean </b> then corresponding
    EJB CMP Filed  will always be   <b>Boolean</b>  in BEA Workshop !</span></p>
    <p class="MsoNormal"><i><span lang="EN-US">Following description considers the
    </span><span lang="EN-US" style="font-size: 11.0pt">PROBLEM</span><span lang="EN-US">:</span></i></p>
    <p class="MsoNormal"><span lang="EN-US">Class<b>
    weblogic.jdbc.utils.schema.Column </b>from<b> weblogic.jar </b>and its method<b>
    String getJavaType() </b>has a <b>switch(getType())</b> with <b>case:</b></span></p>
    <p class="MsoNormal"><span lang="en-us"><b> if(this.getSize() == 1)<br>
        return "boolean"; <br>
    else<br>
        return "String";</b></span></p>
    <p class="MsoNormal"><span lang="en-us">and </span>
    <span lang="EN-US" style="font-size: 12.0pt; font-family: Times New Roman">
    another </span><span lang="en-us"> method <b>String getJavaObjectType() </b>
    {</span></p>
    <p class="MsoNormal"><b><span lang="en-us">String s = this.getJavaType();</span></b></p>
    <p class="MsoNormal"><b><span lang="en-us">...</span></b></p>
    <p class="MsoNormal"><b><span lang="en-us">    
    if(s.equals("boolean"))<br>
            return "Boolean";</span></b></p>
    <p class="MsoNormal"><span lang="en-us"><b>    
    if(s.equals("char"))<br>
            return "Character";</b></span></p>
    <p class="MsoNormal"><span lang="en-us"><b>... }<br>
    </b>but according to </span><span lang="EN-US"><b>switch(getType())</b> which
    has NOT  a<b> 'case' return char</b>, </span><span lang="en-us"><b>
    'Character' </b>will never be returned, so:</span></p>
    <p class="MsoNormal"><span lang="EN-US"><b>@ejbgen:cmp-field</b> of Java type <b>
    Character </b></span><span lang="en-us">will never be generated by Workshop.</span></p>
    <p class="MsoNormal" align="left"><span lang="EN-US">More often than not  I’ve
    ran into this little but disturbing problem, so I’ve corrected <b>
    weblogic.jdbc.utils.schema.Column.getJavaType switch case </b>as:</span></p>
    <p class="MsoNormal" style="text-indent:35.4pt"><b><span lang="EN-US">…</span></b></p>
    <p class="MsoNormal" style="text-indent:35.4pt"><b><span lang="EN-US">       
    case 1:     // '\001'  //</span><span lang="EN-US" style="font-size: 10.0pt">CHAR</span></b></p>
    <p class="MsoNormal" style="text-indent:35.4pt"><b><span lang="EN-US">
                if(this.getSize() == 1)</span></b></p>
    <p class="MsoNormal" style="text-indent:35.4pt"><b><span lang="EN-US">          
         return "char";  </span></b></p>
    <p class="MsoNormal" style="text-indent:35.4pt"><b><span lang="EN-US">…</span></b></p>
    <p class="MsoNormal" style="text-indent:35.4pt"><b><span lang="EN-US">private
    static final boolean </span><span lang="EN-US" style="font-size: 10.0pt">
    CHAR_TO_BOOLEAN</span><span lang="EN-US"> = false;     </span></b><span lang="EN-US">//as
    a field variable</span></p>
    <p class="MsoNormal" style="text-indent:35.4pt"><b><span lang="EN-US">…</span></b></p>
    <p class="MsoNormal" style="text-indent:35.4pt"> </p>
    <p class="MsoNormal" style="text-align:justify"><span lang="EN-US">Using this
    correction and precompiled class I’ve built and tested a lot of projects w/o
    problems so far.</span></p>
    <p>Best regards: George Moykin<p>
    P.S. I appologize to site Admins for posting the same topic in EJB forum, but it refers to EJBs too.

    Hi,<br>
    In your database, we have some columns of CHAR type and this is the decision of our DB architects. I understand the case ‘male’ or ‘female’, true or false, either; but only if I must choose between 2 variants. Our DB columns contain char symbols such as ‘:’, ‘;’,’-’ etc. and for some inner purposes our architects decided DB columns to be of type CHAR, not VARCHAR. In this case, the Workshop transformation ‘CHAR to BOOLEAN’ doesn’t do useful work. So, I’ve decided to modify some weblogic.jar classes (as described) and now I’m able to generate Entity EJB from DBMS Tables w/o manual intervention.<br>
    Best Regards

  • Help on java.sql.Types class

    Hai Friends ,
    I want some help on java.sql.Types class .
    What is the use of the above class ?
    Some details about this class.

    Good Morning Yekesa
    First of all i would like to thank U for looking into my problem.
    I am using java.sql.Types.OTHER for
    {"?=CALL(storedprocedurename.functionname(?))"}
    registerOutParameter(1,javal.sql.Types.OTHER)
    setString(2,"user")
    here the
    second parameter passes an argument to function name ( viz. username say "user")
    and the function will return the ref cursor as follows:
    // declaration in pl/sql procedure
    begin
    rc ref cursor
    open rc for select * from ss_user where login_name="user";
    return rc;
    end
    now the stored procedure has a return value (i.e. stored function) which it needs to register as
    registerOutParameter(1,javal.sql.Types.OTHER)
    and it finally results in the following errors :
    Loading driver
    Before conn stmt
    After conn stmt
    Calling Stored procedure
    Stored procedure called
    java.sql.SQLException: Invalid column type
    at oracle.jdbc.dbaccess.DBError.check_error(DBError.java:243)
    at oracle.jdbc.driver.OracleStatement.get_internal_type(OracleStatement.java:2487)
    at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallableStatement.java:64)
    at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallableStatement.java:54)
    at sptest.<init>(sptest.java:28)
    at sptest.main(sptest.java:49)
    T couldn't understand why it is saying Invalid Column Type because its working fine with both
    java.sql.Types.INTEGER
    and
    java.sql.Types.VARCHAR
    Pl help me at the earliest as i have wasted a lot of time on it.
    pl mail me in detail at [email protected]
    bye then
    bansi
    null

  • Sql type to Java class?

    I want to write a utility class to generate a java source file (bean) from out of the metadata of a database table. the metadata returns the column type as a java.sql.Types constant (int value). now, i want to map these int values to Java classes. (e.g. Types.INT => java.lang.Integer). Is there already such a method in the API or do i have to write my own switch ... case Types.INT ... result = Integer.class ... method?

    well, i wrote my own utility method to generate such beans:
         * Convert SQL type code to corresponding Java class.
         * @param sqlType One of java.sql.Types.xxx.
         * @return Class that corresponds to the given type.
        public static Class toClass(int sqlType) {
            Class result = null;
            switch (sqlType) {
            case Types.BIGINT :
            case Types.INTEGER :
            case Types.SMALLINT :
            case Types.TINYINT :
                result = Integer.class;
                break;
            case Types.BIT :
            case Types.BOOLEAN :
                result = Boolean.class;
                break;
            case Types.CHAR :
                result = Character.class;
                break;
            case Types.DATE :
            case Types.TIMESTAMP :
                result = java.util.Date.class;
                break;
            case Types.DECIMAL :
            case Types.DOUBLE :
            case Types.FLOAT :
                result = BigDecimal.class;
                break;
            case Types.NULL :
                result = null;
                break;
            case Types.LONGVARCHAR :
            case Types.VARCHAR :
            default :
                result = String.class;
                break;
            return result;
        }//toClass()
         * Create a Java bean (source file) to map a database table. The class name is the table name, the bean
         * properties are the table columns. Each column will result in a property with a corresponding set() and
         * get() method.
         * @param connection Database connection to load table from.
         * @param schema Schema to get tables for.
         * @param tableName Name of table to create the bean for.
         * @param className Name of Java class to create.
         * @param fileName Name of Java source file to create.
         * @throws SQLException, IOException
        public static void createTableBean(Connection connection, String schema, String tableName, String className, String fileName)
                throws SQLException, IOException {
            if (connection != null && tableName != null && fileName != null) {
                //read table columns:
                DatabaseMetaData dmd = connection.getMetaData();
                ResultSet resultSet = dmd.getColumns(null, "%", tableName, null);
                Properties props = new Properties();
                if (resultSet != null) {
                    while (resultSet.next()) { //for each table
                        String name = resultSet.getString("COLUMN_NAME");
                        int type = resultSet.getInt("DATA_TYPE");
                        props.setProperty(name, ""+type);
                    }//next table
                }//else: resultSet unavailable
                //create source file:
                File file = new File(fileName);
                StringBuffer sb = new StringBuffer();
                sb.append("/* $Header:$ */\n");
                sb.append("package TODO;\n\n");
                sb.append("/**\n");
                sb.append(" * Container class to store data of one record (row) of table '"+tableName+"'.\n");
                sb.append(" *\n");
                sb.append(" * @version $Revision:$ ($Date:$)\n");
                sb.append(" * @author $Author:$\n");
                sb.append(" */\n");
                sb.append("public class ");
                sb.append(className);
                sb.append(" {\n\n");
                Enumeration enum = props.keys();
                StringBuffer sb2 = new StringBuffer(); //methods
                StringBuffer sb3 = new StringBuffer(); //toString()
                while (enum.hasMoreElements()) {
                    String columnName = (String) enum.nextElement();
                    //change first character of column name to lower case:
                    String fieldName = columnName.substring(0, 1).toLowerCase() + columnName.substring(1);
                    String stype = props.getProperty(columnName, ""+Types.VARCHAR);
                    int type = (new Integer(stype)).intValue();
                    Class javaClass = toClass(type);
                    String typeName = "String"; //default
                    if (javaClass != null) {
                        String javaClassName = javaClass.getName();
                        int lastDot = javaClassName.lastIndexOf('.');
                        if (lastDot >= 0) {
                            typeName = javaClassName.substring(lastDot + 1);
                    //field:
                    sb.append("    /** ");
                    sb.append(columnName);
                    sb.append(" */\n");
                    sb.append("    private ");
                    sb.append(typeName);
                    sb.append(" ");
                    sb.append(fieldName);
                    sb.append(" = null;\n");
                    //toString() method:
                    sb3.append("        sb.append(\",");
                    sb3.append(fieldName);
                    sb3.append("=\");\n");
                    sb3.append("        sb.append(");
                    sb3.append(fieldName);
                    sb3.append(");\n");
                    //set method:
                    sb2.append("    /**\n");
                    sb2.append("     * Set ");
                    sb2.append(columnName);
                    sb2.append(".\n     *\n     * @param value ");
                    sb2.append(columnName);
                    sb2.append(" to set.\n");
                    sb2.append("     */\n");
                    sb2.append("    public void set");
                    sb2.append(columnName);
                    sb2.append("(");
                    sb2.append(typeName);
                    sb2.append(" value) {\n        ");
                    sb2.append(fieldName);
                    sb2.append(" = value;\n    }\n\n");
                    //get method:
                    sb2.append("    /**\n");
                    sb2.append("     * Get ");
                    sb2.append(columnName);
                    sb2.append(".\n     *\n     * @return ");
                    sb2.append(columnName);
                    sb2.append(".\n     */\n");
                    sb2.append("    public ");
                    sb2.append(typeName);
                    sb2.append(" get");
                    sb2.append(columnName);
                    sb2.append("() {\n");
                    sb2.append("        return ");
                    sb2.append(fieldName);
                    sb2.append(";\n    }\n\n");
                }//next column
                sb.append("\n\n");
                sb.append(sb2.toString()); //methods
                //overwrite toString() method:
                sb.append("    /**\n");
                sb.append("     * Overwrite super.\n");
                sb.append("     *\n     * @return String representation of the object.\n");
                sb.append("     */\n");
                sb.append("    public String toString() {\n");
                sb.append("        StringBuffer sb = new StringBuffer(super.toString());\n\n");
                sb.append(sb3.toString());
                sb.append("\n        return sb.toString();\n");
                sb.append("    }\n\n");
                sb.append("}//"+className);
                //write to file:
                String text = sb.toString();
                BufferedWriter bw = null;
                try {
                    bw = new BufferedWriter(new FileWriter(file));
                    bw.write(text, 0, text.length());
                } finally {
                    if (bw != null) {
                        try { bw.close(); } catch (IOException ioe) { /* ignore */ }
            }//else: input unavailable
        }//createTableBean()

  • Java.sql.SQLException: Internal Error: Inconsistent catalog view

    Hi all,
    I have an Oracle procedure defined like:
    pkgoms.p_oms_audit ( in_tab_oms_audit in tab_oms_audit,out_status out number)
    tab_oms_audit is a collection of t_oms_audit
    Here is the structure for the type (with 16 fileds)
    create or replace type t_oms_audit as object(
    Username_ VARCHAR2(101),
    d_Date_ Date,
    <other fields>) ;
    In my Java code I have:
    // conn is the connections to db
    oracle.sql.StructDescriptor structDesc = oracle.sql.StructDescriptor.createDescriptor("TAB_OMS_AUDIT", conn);
    Object[] attributes = new Object[16];
    // Fill out the array: attributes[] in the same structure that t_oms_audit is defined
    // Receive the following error on the next line:
    // java.sql.SQLException: Internal Error: Inconsistent catalog view
    oracle.sql.STRUCT struct = new oracle.sql.STRUCT(structDesc, conn, attributes);
    anOracleCallableStatement.setObject(1, struct, java.sql.Types.STRUCT);
    anOracleCallableStatement.execute();I searched for the above error and the only thing I could find was that its a permission issue; I can execute select, update, insert, delete, ... on db, so not sure if its in fact a permission issue or I am doing sth. else wrong. Any help is greatly appreciated.

    Hi all
    I have the same problem.
    it's not a GRANT problem because in PL/SQL the object works fine.
    JDBC Release problem?
    Any help is greatly appreciated.

  • MS SQL - sql type for Cursor

    Hello,
    Please help. I am using weblogic 8.1 and MS SQL Server 2000. Using JDBC. I have am calling a stored procedure which outputs a CURSOR. I haveing problems specifying the right java.sql.Type for this. I tried java.sql.Type.OTHER but it fails. The code is as follows
    I am planning to return more cursors from the Stored Procedures.
    ====
    Connection conn = null;
    CallableStatement stmt = null;
    String sqlProc = "{ call GetDocumentDetails(?,?) }";
    try {
    conn = this.getConnection();               
    stmt = conn.prepareCall(sqlProc);
    stmt.setInt(1, docId);
    stmt.registerOutParameter(2,Types.OTHER);
    stmt.execute();
    ResultSet rs = (ResultSet) stmt.getObject(2);
    while(rs.next()) {
    The exception that I get is
    java.sql.SQLException: [BEA][SQLServer JDBC Driver]The specified SQL type is not supported by this driver.
         at weblogic.jdbc.base.BaseExceptions.createException(Unknown Source)
    PLEASE HELP.

    Hello,
    Please help. I am using weblogic 8.1 and MS SQL Server 2000. Using JDBC. I have am calling a stored procedure which outputs a CURSOR. I haveing problems specifying the right java.sql.Type for this. I tried java.sql.Type.OTHER but it fails. The code is as follows
    I am planning to return more cursors from the Stored Procedures.
    ====
    Connection conn = null;
    CallableStatement stmt = null;
    String sqlProc = "{ call GetDocumentDetails(?,?) }";
    try {
    conn = this.getConnection();               
    stmt = conn.prepareCall(sqlProc);
    stmt.setInt(1, docId);
    stmt.registerOutParameter(2,Types.OTHER);
    stmt.execute();
    ResultSet rs = (ResultSet) stmt.getObject(2);
    while(rs.next()) {
    The exception that I get is
    java.sql.SQLException: [BEA][SQLServer JDBC Driver]The specified SQL type is not supported by this driver.
         at weblogic.jdbc.base.BaseExceptions.createException(Unknown Source)
    PLEASE HELP.

  • Java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]COUNT field incor

    hello
    i am trying to call stored procedure from javabeans to SQL server database.
    my stored procedure is.....
    =========================================
    CREATE PROCEDURE sp_ins_client1_defect
    /* INSERTS defect AFTER GENERATING A NEW defectid
    RETRUN VALUES -
    1) -101 inser failed
    2) 0 Successfull
    @status tinyint,
    @priority tinyint,
    @complexity tinyint,
    @type tinyint,
    @desc varchar(50),
    @sourcefile varchar(25),
    @sourceloc varchar(100),
    @testcasefile varchar(25),
    @testcaseno char(5),
    @step2reproduce text,
    @comments text,
    @prodver char(8),
    @projid int,
    @keyid int OUTPUT
    AS
    BEGIN TRAN
    select @keyid=max(defectid) from defects where projectid=@projid
    if @keyid is null
    set @keyid =1
    else
    set @keyid=@keyid + 1
    insert into defects (PROJECTID,DEFECTID,STATUSID,PRIORITYID,COMPLEXITYID,DEFECTTYPEID,DESCRIPTION,SOURCEFILENAME,SOURCELOCATION,TESTCASEFILENAME,TESTCASENUMBER,STEPS2REPRODUCE,COMMENTS,PRODUCTVERSION,VERSIONID)
    values (@projid,@keyid,@status,@priority ,@complexity ,@type ,@desc ,@sourcefile,@sourceloc,@testcasefile,@testcaseno,@step2reproduce,@comments ,@prodver ,1)
    IF @@error <> 0
    BEGIN
    ROLLBACK
    return -101
    END
    ELSE
    BEGIN
    COMMIT
    return 0
    END
    =========================================
    my javabeans code snippets is as follows.
    Connection con;
    CallableStatement cstmt;
    private static String theaddcall = "{ ? = call sp_ins_client1_defect ( ?,?,?,?,?,?,?,?,?,?,?,?,?,?,? )}";
    con = DbUtil.getConnection("dts");
    cstmt = con.prepareCall(theaddcall);
    session.setAttribute("attack","akraman2");
    cstmt.registerOutParameter( 1, java.sql.Types.VARCHAR ); //ret code
    cstmt.setInt ( 2, getDefectstatus());
    session.setAttribute("attack","2");
    cstmt.setInt ( 3, priority );
    cstmt.setInt ( 4, complexity);
    cstmt.setInt ( 5, defecttype);
    cstmt.setString( 6 ,desc);
    cstmt.setString( 7, sourcefile);
    session.setAttribute("attack","3");
    cstmt.setString( 8, sourcefileloc );
    cstmt.setString( 9, testcasefile );
    session.setAttribute("attack","4");
    cstmt.setString( 10, testcaseno );
    cstmt.setString( 11, steps2rep );
    cstmt.setString( 12, comments );
    session.setAttribute("attack","5");
    cstmt.setString( 13, prodver );
    cstmt.setInt ( 14, projids );
    cstmt.registerOutParameter(15, java.sql.Types.VARCHAR );
              session.setAttribute("addd","1");
    boolean result=cstmt.execute();
              session.setAttribute("addd","2");
    while (result=cstmt.getMoreResults()) {};
    /* rest of the code is here */
    if possible please solve there query.
    From ShivNarayan

    "{ ? = call sp_ins_client1_defect ( ?,?,?,?,?,?,?,?,?,?,?,?,?,?,? )}";When I count the about I get 16 '?' (one return and 15 args)
    The stored proc only has 14 args and you only populate 14.

  • Java.sql.SQLException: Invalid column index error While getClob()

    I have code which works fine in Iplanet or stand alone Java program using WLS Connection Pool, But not from the the WLS servlet.
    This uses 9.1 Oracle JDBC Thin Driver
    Code snippet:
    cstmt.setString(1, servicename);
    cstmt.setString(2, params);
    String resultXmlString = null;
    cstmt.registerOutParameter(3,java.sql.Types.CLOB);
    cstmt.execute();
    Clob clob = cstmt.getClob(3);
    int val;
    long size = clob.length();
    StringBuffer full_text = new StringBuffer();
    if (clob != null)
    java.io.Reader clobReader = clob.getCharacterStream();
    while((val = clobReader.read()) > 0)
    full_text.append((char) val);
    resultXmlString = full_text.toString();

    I have code which works fine in Iplanet or stand alone Java program using WLS Connection Pool, But not from the the WLS servlet.
    This uses 9.1 Oracle JDBC Thin Driver
    Code snippet:
    cstmt.setString(1, servicename);
    cstmt.setString(2, params);
    String resultXmlString = null;
    cstmt.registerOutParameter(3,java.sql.Types.CLOB);
    cstmt.execute();
    Clob clob = cstmt.getClob(3);
    int val;
    long size = clob.length();
    StringBuffer full_text = new StringBuffer();
    if (clob != null)
    java.io.Reader clobReader = clob.getCharacterStream();
    while((val = clobReader.read()) > 0)
    full_text.append((char) val);
    resultXmlString = full_text.toString();

Maybe you are looking for