Package noNamespace

Examples of noNamespace.TABLEDATADocument


        return ans;
    }

    public void doExport(String sqlStatement, File fHandle) throws Exception{
        Rep("Will execute <"+sqlStatement+">");
        TABLEDATADocument doc = TABLEDATADocument.Factory.newInstance();
        TABLEDATA tableData = doc.addNewTABLEDATA();
        EXPORTINFO exportInfo = tableData.addNewEXPORTINFO();
        exportInfo.setSTATEMENT(sqlStatement);
        exportInfo.setTIMESTAMP(Calendar.getInstance());
        ResultSet prs = oraConnection.prepareCall(sqlStatement).executeQuery();
        ResultSetMetaData columns = prs.getMetaData();
        int colCount = columns.getColumnCount();
        Rep("Statement returns "+colCount+" columns");
        String wColumns = "";
        for(int i=0;i<colCount;i++){
            COLUMNTYPE colType = exportInfo.addNewCOLUMNTYPE();
            colType.setNAME(columns.getColumnName(i+1));
            colType.setTYPE(columns.getColumnTypeName(i+1));
            if(columns.getColumnTypeName(i+1).equalsIgnoreCase("DATE")){
                colType.setFORMATMASK(DATE_FORMAT);
            }
            colType.setTABLENAME(columns.getTableName(i+1));
            if(i==0){
                wColumns = getNewColumn(columns,i+1);
            } else {
                wColumns = wColumns+","+getNewColumn(columns,i+1);
            }
        }
        String newSql = sqlStatement.substring(sqlStatement.toUpperCase().indexOf(" FROM "));
        newSql = "select "+wColumns+newSql;
        Dbg(newSql);
        ResultSet rs = oraConnection.prepareCall(newSql).executeQuery();
        int line=0;

        while(rs.next()){
            line++;
            ROW row = tableData.addNewROW();
            Rep("Exporting record "+ line);
            for(int i=0;i<colCount;i++){
                COLUMN col = row.addNewCOLUMN();
                col.setCOLUMNNAME(columns.getColumnName(i+1));
                col.setDATA(getColumnData(rs,i+1,columns.getColumnTypeName(i+1)));
            }
        }
        Rep("Finished!");
        doc.save(fHandle);
    }
View Full Code Here


    public void doImport(String tableName, File fHandle) throws Exception{
        oraConnection.setAutoCommit(false);
        int i = 0;
        Rep("Will import "+fHandle.getAbsolutePath()+" into "+tableName);
        TABLEDATADocument doc = TABLEDATADocument.Factory.parse(fHandle);
        Rep("Used sql:  "+doc.getTABLEDATA().getEXPORTINFO().getSTATEMENT());
        Rep("Timestamp: "+doc.getTABLEDATA().getEXPORTINFO().getTIMESTAMP().toString());
        String str = "insert into "+tableName+" values(";
        for(COLUMNTYPE cols : doc.getTABLEDATA().getEXPORTINFO().getCOLUMNTYPEArray()){
            i++;
            Rep(i+":"+cols.getNAME()+" - "+cols.getTYPE()+" = "+cols.getFORMATMASK());
            if(i==1){
                str = str+" ? ";
            } else {
                str = str+",?";
            }
        }
        str = str+")";
        Dbg(str);
        PreparedStatement ps = oraConnection.prepareStatement(str);
        for(ROW row : doc.getTABLEDATA().getROWArray()){
            i=0;
            for(COLUMN col : row.getCOLUMNArray()){
                i++;
                if(doc.getTABLEDATA().getEXPORTINFO().getCOLUMNTYPEArray(i).getTYPE().equalsIgnoreCase("CLOB")){
                    Clob clob =Clob.class.newInstance();
                    clob.setString(0, col.getDATA());
                    ps.setClob(i-1, clob);
                }else if(doc.getTABLEDATA().getEXPORTINFO().getCOLUMNTYPEArray(i).getTYPE().equalsIgnoreCase("DATE")){
                    ps.setDate(i-1, null);
                }else{
                    ps.setString(i-1, col.getDATA());
                }
            }
View Full Code Here

TOP

Related Classes of noNamespace.TABLEDATADocument

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.