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()

Similar Messages

  • Using oracle.sql.BLOB data type in Java Class to pass in a Blob

    All,
    I'm trying to pass in a BLOB from PL/SQL to a Java Class, but the BLOB isn't passed correctly.
    When I check the length of the BLOB in PL/SQL its different from the length of the BLOB in java.
    I'm using DB 11g and the ojdbc5.jar file in my java classes.
    The java function uses the oracle.sql.BLOB type to get the parameter.
    The java class is loaded into the DB and called via a PL/SQL function.
    Kind regards,
    Nathalie

    The question is indeed a little ambigious defined ;o)
    When I pass the BLOB to the java method and invoke BLOB.getBytes() and then get the length of the BLOB in java the length of the BLOB is bigger than in PL/SQL.
    When I use the method 'getBinaryStream' and write this to a buffer, the code works.
    I will log a tar regarding the getBytes()-method to ask for more detailed information regarding the methods provided using the JDBC Drivers.
    Kind regards,
    Nathalie

  • Accessing MS Sql Server with Java classes - problem connecting to socket

    I found an example at this location which uses java classes to connected to MS Sql Server.
    http://search400.techtarget.com/tip/1,289483,sid3_gci1065992,00.html
    --bummer - it is a login location - so I will include the article
    Anyway, the example is using Websphere, but I am still on Jbuilder (will get wsad soon). So I planted the classes from the example in
    C:\Borland\JBuilder\jkd1.4\jre\lib\ext\...the classes
    Then I copied the code from the example to my jpx project and got an error that it could not connect to the socket. The only thing I changed in the code was the connection string:
    --original string from example:
    Connection connection = DriverManager.getConnection("jdbc:microsoft:sqlserver://1433", "");
    I was getting an error with the 2 argument version of DriverManager - and the second argument here was empty (properties argument). Here was my connection string:
    Connection connection = DriverManager.getConnection("jdbc:microsoft:sqlserver://Myserver:1433;User=sa;Password=");
    I am only using the 1 argument version of DriverManager. Note that the password=" is blank because my RnD workstation is standalone - no one accesses the sql server except me - so no password. I also left out the last semicolon I noticed. Any suggestions appreciated how I could fix this.
    Thanks
    source of article:
    http://search400.techtarget.com/tip/1,289483,sid3_gci1065992,00.html
    iSeries 400 Tips:
    TIPS & NEWSLETTERS TOPICS SUBMIT A TIP HALL OF FAME
    Search for: in All Tips All search400 Full TargetSearch with Google
    PROGRAMMER
    Sample code: Accessing MS SQL Server database from the iSeries
    Eitan Rosenberg
    09 Mar 2005
    Rating: --- (out of 5)
    Nowadays with the help of Java the iSeries can be integrated with other databases quite easy. This tip shows you how. The code included here uses the free Microsoft driver that can be downloaded from here. (SQL Server 2000 Driver for JDBC Service Pack 3)
    If your SQL server does not include the Northwind Sample Database you can find it here.
    http://www.microsoft.com/downloads/details.aspx?familyid=07287b11-0502-461a-b138-2aa54bfdc03a&displaylang=en
    The download contains the following files:
    msbase.jar
    mssqlserver.jar
    msutil.jar
    Those files needs to be copied to the iSeries directories (/home/r_eitan/ExternalJARs).
    Here's the directory structure (on the iSeries) for this sample:
    /home/r_eitan/ExternalJARs - Microsoft files (msbase.jar,mssqlserver.jar,msutil.jar)
    /home/r_eitan/JdbcTest02 - My code (Main.java,Main.class)
    The Java code
    import java.sql.*;
    import java.io.*;
    class Main {
    * Connect to Microsoft SQL server and download file northWind.products as tab
    * seperated file. (products.txt)
    public static void main(String args[]) {
    try {
    PrintStream outPut = new PrintStream(new BufferedOutputStream(new FileOutputStream("products.txt")));
    Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
    //Connection connection = DriverManager.getConnection("jdbc:microsoft:sqlserver://1433", "");
    Connection connection = DriverManager.getConnection("jdbc:microsoft:sqlserver://Myserver:1433;User=sa;Password=");
    System.out.println("Connection Done");
    connection.setCatalog("northWind");
    String sqlCmdString = "select * from products";
    Statement statement = connection.createStatement();
    ResultSet resultSet = statement.executeQuery(sqlCmdString);
    ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
    int columnCount = resultSetMetaData.getColumnCount();
    // Iterate throught the rows in resultSet and
    // output the columns for each row.
    while (resultSet.next()) {
    for (int index = 1; index <=columnCount; ++index)
    String value;
    switch(resultSetMetaData.getColumnType(index))
    case 2 :
    case 3 :
    value = resultSet.getString(index);
    break;
    default :
    value = """ + resultSet.getString(index) + """;
    break;
    outPut.print(value + (index < columnCount ? "t" : ""));
    outPut.println();
    outPut.close();
    resultSet.close();
    connection.close();
    System.out.println("Done");
    catch (SQLException exception)
    exception.printStackTrace();
    catch (Exception exception)
    exception.printStackTrace();
    --------------------------------------------------------------------------------------------------

    My guess is that the server's host name isn't right. It necessarily (or even usually) the "windows name" of the computer. Try with the numeric IP address instead (type "ipconfig" to see it).
    First aid check list for "connection refused":
    - Check host name in connect string.
    - Check port number in connect string.
    - Try numeric IP address of server host in connect string, in case name server is hosed.
    - Are there any firewalls between client and server blocking the port.
    - Check that the db server is running.
    - Check that the db server is listening to the port. On the server, try: "telnet localhost the-port-number". Or "netstat -an", there should be a listening entry for the port.
    - Try "telnet serverhost the-port-number" from the client, to see if firewalls are blocking it.
    - If "telnet" fails: try it with the numeric ip address.
    - If "telnet" fails: does it fail immediately or after an obvious timeout? How long is the timeout?
    - Does the server respond to "ping serverhost" or "telnet serverhost" or "ssh serverhost"?

  • Passing array of Types to java class

    I am trying to pass a user defined type (that is an array) from PL/Sql to a javaclass. Here are the definitions that make-up the parameter to pass from PL/Sql to Java (uri_digest_array):
    CREATE OR REPLACE TYPE uri_digest as object (uri VARCHAR2(256),
    digest_value CLOB);
    CREATE OR REPLACE TYPE uri_digest_array AS VARRAY(10) OF uri_digest;
    In Oracle-land, java classes are published to PL/Sql by way of the following definition. Note that the intent here is to have compatible data-types.
    CREATE OR REPLACE FUNCTION SIGNRETURNINGXML (p_array IN uri_digest_array)
    RETURN LONG
    AS LANGUAGE JAVA
    NAME 'SignReturningXml.main(oracle.sql.Array) return java.lang.String';
    Here is a fragment of the java class code:
    class SignReturningXml {
    public static String main(String [] [] signItems ) // I have no idea what datatype to use here!
    { . . . . The code in here would process the passed array normally from first entry to last.
    Currently I get the following error:
    PLS-00311: the declaration of
    "SignReturningXml.main(oracle.sql.Array) return
    java.lang.String" is incomplete or malformed
    I could use some suggestions on resolving the datatype conflicts. Any ideas? Has anyone tried this kind of thing?
    Thanks,
    Michael

    Michael,
    At the risk of another [non] useful response, I meant that you should try searching the "Ask Tom" Web site, because usually you will find an answer to your question that has already been asked by someone else. Perhaps these will be helpful:
    [url=http://asktom.oracle.com/pls/ask/f?p=4950:8:1320383202207153292::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:8908169959941
    ]Can I Pass a nested table to Java from a pl/sql procedure
    [url=http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:712625135727
    ]passing arrays into pl/sql stored procedures
    Good Luck,
    Avi.

  • How to return Values from Oracle Object Type to Java Class Object

    Hello,
    i have created an Oracle Object Types in the Database. Then i created Java classes with "jpub" of these types. Here is an example of the type.
    CREATE OR REPLACE TYPE person_type AS OBJECT
    ID NUMBER,
    vorname VARCHAR2(30),
    nachname VARCHAR2(30),
    geburtstag DATE,
    CONSTRUCTOR FUNCTION person_type RETURN SELF AS RESULT,
    CONSTRUCTOR FUNCTION person_type(p_id NUMBER) RETURN SELF AS RESULT,
    CONSTRUCTOR FUNCTION person_type(p_vorname VARCHAR2,
    p_nachname VARCHAR2,
    p_geburtstag DATE) RETURN SELF AS RESULT,
    MEMBER FUNCTION object_exists(p_id NUMBER) RETURN BOOLEAN,
    MEMBER PROCEDURE load_object(p_id NUMBER),
    MEMBER PROCEDURE save_object,
    MEMBER PROCEDURE insert_object,
    MEMBER PROCEDURE update_object,
    MEMBER PROCEDURE delete_object
    MEMBER PROCEDURE load_object(p_id NUMBER) IS
    BEGIN
    SELECT p.id, p.vorname, p.nachname, p.geburtstag
    INTO SELF.ID, SELF.vorname, self.nachname, SELF.geburtstag
    FROM person p
    WHERE p.id = p_id;
    END;
    My problem is, that if i use the member function "load_object" from my java app it doesnt return the selected values to the java class and i dont know why. I use the java class like this:
    PersonObjectType p = new PersonObjectType();
    p.load_object(4);
    There is a reocrd in the database with id = 4 and the function will execute successful. But if i try to use "p.getVorname()" i always get "NULL". Can someone tell me how to do that?
    Thanks a lot.
    Edited by: NTbc on 13.07.2010 15:36
    Edited by: NTbc on 13.07.2010 15:36

    CallableStatement =
    "DECLARE
    a person_type;
    BEGIN
    a.load_object(4);
    ? := a;
    END;"
    And register as an out parameter.
    Edited by: michael76 on 14.07.2010 05:01

  • (262119469) Q DBC-17 How is data mapped from SQL-type to Java-type?

    Q<DBC-17> Is there any documentaion for the data mapping between the "java type" and
    the "sql type"
    A<DBC-17> The data types are the standard JDBC mappings. Check the javadoc for the
    java.sql package.

    Hi,
              If you are seeing last 3 fields coming as empty.... then you need to check the seperator type which correctly seperats one fields from another during mapping to BW infoobject.
    Thanks
    Kishore Kusupati

  • Generate sql from mappingtool java class

    I have been trying without any luck to get the MappingTool.run(...) method
    to generate an SQL update script. To do this I figure that I need to
    specify the "sqlWriter" parameter as a valid FileWriter. But the file
    mappingtool generates is always empty. Any hints/clues?
    Note that I have no problem generating the sql files from ant or commandline
    by specifying -sql xxx.sql
    Here is my calling code...
    Writer dest = new FileWriter(...);
    boolean ok =
    MappingTool.run(
    this.getJDBCConfiguration(), // JDBCConfiguration
    MappingTool.ACTION_BUILD_SCHEMA, // action
    this.getResourceKeys().getJDOResourceFileNames(), // jdo file names
    null, // mappingWriter
    SchemaTool.ACTION_ADD,// schemaAction
    false,// dropTables
    false,// ignoreErrors
    true, // readSchema
    true, // include pks
    true, // include fks
    true, // include indexes
    null, // schemaWriter
    dest, // sqlWriter
    this.getClass().getClassLoader() // class loader
    Cheers and thanks.
    ..droo.

    Does the schema already exist? If so, SchemaTool.ACTION_ADD won't do
    anything (nothing to add). Try SchemaTool.ACTION_BUILD

  • Loading an SQL in a Java Class

    Hi Forum
    I'm writing a test for some of my work and I want to load some data into a mysql db. How do I do that From my Java testfile?
    I know I could load it manually before running the test but I want it to be loaded by the testclass when I run the testclass.
    tia

    Do a search in the Java Database Connectivity (JDBC) forum - it should contain hundreds of examples of how to use JDBC with a MySQL database.
    However, direct JDBC access is not always the best way to load in a large dataset - if you've got a command-line means of importing the data then you might find it better to call that directly using Runtime.exec.
    Hope this helps.

  • Mapping SQL data types (especially SMALLINT) to Java classes

    I want to know the reason for a certain pair of exceptions in JDBC�s mapping of SQL data types to Java classes.
    Sun�s web site ( http://java.sun.com/j2se/1.4.2/docs/guide/jdbc/getstart/mapping.html ), Sybase�s site, and other sites contain mappings from SQL data types to Java primitive data types and/or Java classes. On that Sun web page, Section 9.9.1 maps mostly to Java primitive data types, and Section 9.9.3 maps mostly to Java classes. For the SQL data types that map to both primitive data types and classes, the class is typically the wrapper class of the primitive data type. For example, SQL�s DOUBLE data type maps to both the double primitive data type and its wrapper class (Double). However, Section 9.7 of that Sun web page says that there are exceptions for SQL�s TINYINT and SMALLINT. As expected, they map to the byte and short primitive data types, but they map to the Integer class, not the Byte and Short classes (which are the wrapper classes for byte and short). The web page does not state the reason for this pair of exceptions. It seems to me that SMALLINT data would either work for both short and Short or fail for both short and Short. I don�t see why it would work for short but fail for Short (as the web page implies).
    Can anybody think of a reason for the pair of exceptions? Thanks.

    ghs wrote:
    1) If a DBMS deals with the short and byte primitive data types (as the various web pages imply that it does), then why would it not deal with the Short and Byte wrapper classes?As another guess, because conversions get a little weird in java. Or at least they did in the past. As I recall (with not a lot of clarity) it is possible to do something like pass a perfectly valid string value into a short and get an exception. Whereas using Integer and then converting to Short works.
    Keep in mind that these are guesses.
    3) What I really want to know is this: If I use wrapper classes of Short and Byte (instead of Integer), what will be the harmful consequences (IF ANY)? So far, I have done some trivial testing with a Short for a SMALLINT column (I have not yet tried any TINYINT columns), and it seems to be working.I considered it risky to not test all target databases and drivers.
    Obviously testing will reveal problems.
    If you don't want to test then you might want to stick with integers.

  • Importing Java Classes for Bussiness Logic in Forms6i

    I have created a Java Class with some bussiness logic in it and i m able to impotr it in Forms 6i BUT when it converts my java method into program unit it automatically changes the name of the method with some code ..like method name is "increment" it will make it as "increment_3137" and also one parameter of Ora_java.object type will be added ....WHY is THAT ???and how to work for hat ...even when i m executing the method with the parameter it gives some Exception that Non-Oracle Exception ...and my class individually runs perfectly fine ...CAN U HELP ME ASAP ...Please as its urgent
    Thanx..

    Once you have imported java class files on forms throgh java import class option..
    it creates a pl/sql for the java class that you have imported.
    names for the procedures are assigned by machine code, so dont worry about it..
    for eg. if the name of a method in java class is Increment and after loading java class file the name of ur pl/sql is increment_1254.
    when u call increment_1254 and pass parameter to the procedure ur class incerement will be called and desired operation will be performed.
    ora_java.object is the objec that will be used to access the the class file.
    as java is object oriented it requires a object to execute method of class.
    so u have to initialize the object..
    e.g. increment_1234 (ora_java.object,a,b) is ur procedure
    to call this procedure do the following
    declare
    PASS ORA_JAVA.JOBJECT;
    a,b integer;
    begin
    pass := <classname>.new;     --new will be created if ur class is public or u got public constructor in ur class.
    increment_1234 (pass,a,b) ; -- increment_1234 (ora_java.object,a,b) ;
    end;

  • SQL user defined type mapping with Java Class type

    SECRET_TAB_TYPE is userdefined type in SQL Schema. but accessing this way it is giving invalid column type error(see code below )??
    I have made a class with same name attributes as in SQL Type
    Connection con = DriverManager.getConnection(URL,Username, Password );
    java.util.Map map = con.getTypeMap();
    map.put("SchemaName.SECRET_TAB_TYPE",Class.forName("SECRET_TAB_TYPE"));
    CallableStatement pstmt = con.prepareCall( "{ call smartapi.FetchSharedSecret(?,?,?,?,?,?) }" );
    pstmt.setString(1,"SM");
    pstmt.setString(2,"BT");
    pstmt.setString(3,"COM");
    pstmt.registerOutParameter(4, Types.JAVA_OBJECT);//
    pstmt.registerOutParameter(5,Types.VARCHAR);
    pstmt.executeQuery();
    secret_tab=(SECRET_TAB_TYPE)pstmt.getObject(4);
    message= pstmt.getString(5);

    STATS_T_TEST_
    docs.oracle.com/cd/B19306_01/server.102/b14200/functions157.htm 
    STATS_T_TEST_ONE: A one-sample t-test
    STATS_T_TEST_PAIRED: A two-sample, paired t-test (also known as a crossed t-test)
    STATS_T_TEST_INDEP: A t-test of two independent groups with the same variance (pooled variances)
    STATS_T_TEST_INDEPU: A t-test of two independent groups with unequal variance (unpooled variances)

  • 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

  • Generate Java class from Oracle Type defined in Package w/ JPublisher

    I was wondering if its possible to generate a Java class for an Oracle Type defined in a Package? I know passing the package name to JPublisher (SQL <package_name>) causes all Oracle Types in the Package to have a Java class generated for them but I'd like to be able to do this for an individual Type defined in a Package (something like SQL <package_name>.<type_name>).
    Thanks for any information you can give me.

    Hi Marinel,
    The support for XSD import is limited on 10.1.2. If you can, you should consider moving to the 10.1.3 preview as the support for document style web services has improved. The other option will be to inline the schema in your WSDL.
    Eric.

  • Calling PL/SQL function from external Java class

    I was wondering if I was able to call a pl/sql function from an external java class? If so, would you be able to tell me briefly on how to go about it. I know I can call java methods that are internally stored in the db from pl/sql, but I was hoping I could call pl/sql from external java. Thanks,
    Kelly

    Ok, I made the changes, but I'm now getting the following error:
    Error code = 1403
    Error message = ORA-01403: no data found
    ORA-06512: at "IOBOARD.GETSTATUS", line 6
    ORA-06512: at line 1
    The ora-01403 I don't understand because there is data for the name Kelly.Brace.
    ora-06512 error: at string line string.
    Here's what the code looks like after I made the changes:
    String sql = "{?=call ioboard.GetStatus(?)}";
          // create a Statement object
          myStatement = myConnection.prepareCall( sql );
          myStatement.setString( 1, "Kelly.Brace" );
          myStatement.registerOutParameter(2, java.sql.Types.LONGVARCHAR );
          // create a ResultSet object, and populate it with the
          // result of a SELECT statement
          ResultSet myResultSet = myStatement.executeQuery();
          // retrieve the row from the ResultSet using the
          // next() method
          myResultSet.next();
          // retrieve the user from the row in the ResultSet using the
          // getString() method
          String status = myResultSet.getString(1);
          System.out.println("Hello Kelly, your status is: " + status);
          // close this ResultSet object using the close() method
          myResultSet.close();Here's what the function looks like:
    CREATE OR REPLACE FUNCTION GetStatus( user_name in varchar2)
    RETURN VARCHAR2
    is
    v_status varchar2(10);
    BEGIN
    select iob_location into v_status
    from ioboard.iob_user
    where iob_username = user_name;
      RETURN( v_status);
    END;This works perfectly in the SQL Window:
    select iob_location
    from ioboard.iob_user
    where iob_username = 'Kelly.Brace';

  • 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.

Maybe you are looking for

  • Essbase, shared services, projects, users

    I have installed shared services and cnfigured it now installed essbase EAS Provider services and configured in the above mentioned manner (DID not start essbase and EAS till now) when I log into shared services....i see only bussines rules under pro

  • IHow to monitor Incomming and put going Mail Trafic..?

    Dear all, I am using (Sun Java(tm) System Messaging Server version 6.30.15). I want to monitor All the in-coming mails and out-going mails. Basically, i want to get an idea about , how many mails we are getting per day....etc... How many mails send v

  • Need to find out what has been modified to running-config

    Hello, When I enter the "reload" command, Cisco ASA 5510 asks me a question: System config has been modified Save? [Y]es/[N]o: All I did was issuing a few "show" commands before the "reload" command. I definitely need to find out what has been modifi

  • Spatial dimension in OWB

    Hello,   Actually, I'm trying to use sdo_geometry data type in a DW dimension in OWB. But this type is not shown in the datatypes list of attributes in OWB. Does anybody have an idea how to do it ? Thanks.

  • How-to: Servlet -- Servlet comunication.

    The scheme is about some servlets comunicating with others that realize the data set of the structure. How is the best way to let the servlets comunicate between them? Java is offering different techniques for let comunicating like http requests, dat