JDBC Column Name Not Writing

I am using the following to return a results set from SQL Server and writing it to a text file. The data in the writes to the file, but I can not get the column name to write to the file.
flNewExcelFile oflTemp = new flNewExcelFile();
File flTemp = oflTemp.svFile();
BufferedWriter outData = new BufferedWriter(new FileWriter(flTemp));
String dtRow;
ResultSet rsRs = rsSPResult.rsObj();
ResultSetMetaData mtdData = rsRs.getMetaData();
int cols = mtdData.getColumnCount();
for (int i=1;i<=cols;i++)
dtRow = mtdData.getColumnName(i);
outData.write(dtRow);
outData.newLine();
while (rsRs.next())
for (int i=1;i<=cols;i++)
dtRow = rsRs.getString(mtdData.getColumnName(i));
outData.write(dtRow);
outData.newLine();
outData.close();
I am connecting to the data via a DSN-Less connection:
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String sourceURL = "jdbc:odbc:DRIVER={SQL Server}; Server=ServerName;Database=dataBaseName";
databaseConnection = DriverManager.getConnection(sourceURL,"UserID","PW");
And creating the results set:
Statement sqlStatement = conn.createStatement();
ResultSet rsData = sqlStatement.executeQuery("Select * From Contract");
TIA

but I can not get the column name to write to the file.what happens?
looks like you are writing an m$ excel sheet.
1. you are possibly missing something in the steps needed to get column names into you flNewExcelFile object.
2. are you getting the columns names as a row, rather than the header?
if that is so, you might have to write the column names in some particular manner.
3. what is this flNewExcelFile class. the documentation to flNewExcelFile might give you the answer, if it is a third party class.

Similar Messages

  • How to know column name (not an expression) used by function-based index?

    Hi guys,
    Is there any way to know exact column name used by FBI? If I correct, there is SYS.ICOLDEP$ table that has mapping between index/table columns, but I don't see how it could be uniquely joined with the rest. I know about USER_IND_EXPRESSIONS, but the task is to know exact column name, not it's expression.
    This required by our so-called SQL preprocessing of DB schema update utility, which parses stmt (INSERT in our case) and should check against PK/UNIQUE key values.
    Thanks!

    I don't think this is possible in 10g or 11g because :
    1. dictionary keeps track of column number in index and not in table
    2. the expression used in CREATE INDEX is a system generated column
    You would have to parse the expression from USER_IND_EXPRESSIONS:
    SQL> create table t(x int, y int);
    Table created.
    SQL> create index fbi on t(y+1);
    Index created.
    SQL> column index_name format a10
    SQL> column column_name format a20
    SQL> column column_expression format a10
    SQL> select i.index_name, ic.column_name, ic.column_position as iccn, ie.column_position as iecn, ie.column_expression
      2  from user_indexes i , user_ind_columns ic, user_ind_expressions ie
      3  where i.index_name = ic.index_name
      4  and i.index_name = ie.index_name
      5  and i.index_name =  'FBI';
    INDEX_NAME COLUMN_NAME                ICCN       IECN COLUMN_EXP
    FBI        SYS_NC00003$                  1          1 "Y"+1

  • Strange error "Invalid column name 'not applicable'

    When I am trying this piece of code on Solaris 10 having sybase ASE 12.5 installed :
    ResultSet rs = stmt.executeQuery("sp_helpdb master");
    while(rs.next()){
    System.out.println(rs.getString(1));
    I am getting the following error:
    Invalid column name 'not applicable'
    This query returns multiple result sets.
    I am able to print all values in the first result set only.
    Its failing in rs.next();
    I am using jConnect 5.2 driver.
    The same query is executing fine on Solaris 8 having ASE 12.0 installed.
    If i use :
    ResultSet rs = stmt.executeQuery("sp_helpdb master");
    then there is no problem in Solaris 10
    Plz help me.
    Its urgent

    You need to use execute() not executeQuery() in the scenario below and use the multi-result set logic
    If you are using jConnect, see the samples for an example.

  • Error in COLMAP clause. Column name not found

    Hi guys,
    I must be missing something extremely simple here but I can't figure it out. I have a very simple test I am trying to perform. Remap a column from 1 table into another on replicat.
    I have created the defgens file.
    * Definitions created/modified 2013-02-12 13:08
    * Field descriptions for each column entry:
    * 1 Name
    * 2 Data Type
    * 3 External Length
    * 4 Fetch Offset
    * 5 Scale
    * 6 Level
    * 7 Null
    * 8 Bump if Odd
    * 9 Internal Length
    * 10 Binary Length
    * 11 Table Length
    * 12 Most Significant DT
    * 13 Least Significant DT
    * 14 High Precision
    * 15 Low Precision
    * 16 Elementary Item
    * 17 Occurs
    * 18 Key Column
    * 19 Sub Data Type
    Definition for table BILLING.B1
    Record length: 92
    Syskey: 0
    Columns: 2
    B_ID 64 50 0 0 0 1 0 50 50 50 0 0 0 0 1 0 1 2
    B_F_NAME 64 30 56 0 0 1 0 30 30 0 0 0 0 0 1 0 0 0
    End of definition
    Definition for table BILLING.B2
    Record length: 92
    Syskey: 0
    Columns: 2
    B_ID 64 50 0 0 0 1 0 50 50 50 0 0 0 0 1 0 1 2
    B_L_NAME 64 30 56 0 0 1 0 30 30 0 0 0 0 0 1 0 1 0
    End of definition
    I have setup the replicat to read the sourcedefs and remap the column
    -- Identify the Replicat group:
    REPLICAT rxtest
    -- State that source and target definitions are identical:
    --ASSUMETARGETDEFS
    SOURCEDEFS /u12/oracle/golden_gate_11_rep/dirsql/defgen_billing.sql
    --Discard Setup
    DISCARDFILE /u12/oracle/golden_gate_11_rep/dirout/rxtest.txt , PURGE
    SETENV (NLS_LANG="AMERICAN_AMERICA.WE8MSWIN1252")
    -- Specify database login information as needed for the database:
    USERID gg, PASSWORD
    -- Specify error handling rules:
    REPERROR (DEFAULT, ABEND)
    DDL EXCLUDE ALL
    MAP billing.b1, TARGET billing.r1,
    COLMAP (
    B_ID = id,
    b_f_name = f_name);
    Now when I try and start the rxtest replicat I get this error in the report.
    MAP resolved (entry BILLING.B1):
    MAP BILLING.B1, TARGET billing.r1, COLMAP ( B_ID = id, b_f_name = f_name);
    ...( B_ID = id, b_f_name = f_name...
    ^
    Error in COLMAP clause. Column name not found.
    Any ideas? Thanks

    desc billing.r1 - does that table have columns that you've included in the map clause?
    But, check the ordering of the columns in colmap - it goes target_column_name = source_column_name, looks like you have that reversed.
    I don't know why people insist on using SQL file extensions on def files, and placing them in the dirsql directory. What was wrong with using the (already created for you) dirdef directory? And naming the file with an extension like def or defs? It is not a SQL file.

  • Add header record with column names while writing csv file fileAdapter?

    Hi I am writing the output of a query to csv file using fileadapter. but the file generated does not have the header record with the column names. how can I achieve this. please help.

    I'm trying to do the same, but something is not right with my syntax and I haven't been able to resolve all day. Can someone spot what I'm doing wrong?
    Here is the variable with the data I want to insert as the headers for the CSV:
    Updated variable "CPARWebJEHeaders"
    <CPARWebJEHeaders>
    <Root-Element xmlns="http://xmlns.oracle.com/CPWebJEARWrite">
    <CPARWebJE>
    <Project>Project</Project>
    <Organization>CC_Org</Organization>
    <Account>Account</Account>
    <TransactionAmount>Amount</TransactionAmount>
    <TransactionDesc>Description</TransactionDesc>
    </CPARWebJE>
    </Root-Element>
    </CPARWebJEHeaders>
    Here is the InputVariable data for my invoke to the File Adapter:
    [2008/03/24 15:27:30] Updated variable "WriteCPARWebJEFile_Write_InputVariable"
    <WriteCPARWebJEFile_Write_InputVariable>
    <part xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Root-Element">
    <Root-Element xmlns="http://xmlns.oracle.com/CPWebJEARWrite">
    <ns0:CPARWebJE xmlns:ns0="http://xmlns.oracle.com/CPWebJEARWrite">
    <ns0:Project>INV08-00002</ns0:Project>
    <ns0:Organization>1.6.1.1.01</ns0:Organization>
    <ns0:Account />
    <ns0:TransactionAmount>176</ns0:TransactionAmount>
    <ns0:TransactionDesc />
    </ns0:CPARWebJE>
    <ns0:CPARWebJE xmlns:ns0="http://xmlns.oracle.com/CPWebJEARWrite">
    <ns0:Project>INV08-00001</ns0:Project>
    <ns0:Organization>1.6.1.1.01</ns0:Organization>
    <ns0:Account />
    <ns0:TransactionAmount>305.46</ns0:TransactionAmount>
    <ns0:TransactionDesc />
    </ns0:CPARWebJE>
    </Root-Element>
    </part>
    </WriteCPARWebJEFile_Write_InputVariable>
    This is my latest iteration of the insertBefore command, which is done right after the transformation populating the variable above:
    <bpelx:assign>
    <bpelx:insertBefore>
    <bpelx:from variable="CPARWebJEHeaders" query="/ns12:Root-Element/ns12:CPARWebJE"/>
    <bpelx:to variable="WriteCPARWebJEFile_Write_InputVariable" part="Root-Element"/>
    </bpelx:insertBefore>
    </bpelx:assign>
    And finally, here is the current error message:
    <selectionFailure xmlns="http://schemas.xmlsoap.org/ws/2003/03/business-process/">
    <part name="summary">
    <summary>Assign Operation Misuse. The parent of the selection result does not exist or is not an XML element; insertBefore operation cannot be performed. Please check the BPEL source at line number "96" .</summary>
    </part>
    </selectionFailure>
    I understand the error message, but for the life of me can't get it resolved. Trying to change the "to" variable, I can't even get the process to deploy. FYI this is on 10.1.2 and I can't go to 10.1.3 yet, but I think this is a syntax issue and not related to the version.
    Thanks!
    Message was edited by:
    user623606

  • JTable, column names not appearing!

    I am using the following code:
    Vector columnNames = new Vector();
            Vector data = new Vector();
            try
                //  Connect to the Database
                Common.Data.DataAccesser da = new Common.Data.DataAccesser();
                Connection connection = da.getConnection();
                //  Read data from a table
                String sql = "Select * from schedule1";
                Statement stmt = connection.createStatement();
                ResultSet rs = stmt.executeQuery( sql );
                ResultSetMetaData md = rs.getMetaData();
                int columns = md.getColumnCount();
                //  Get column names
                for (int i = 1; i <= columns; i++)
                    columnNames.addElement( md.getColumnName(i) );
                //  Get row data
                while (rs.next())
                    Vector row = new Vector(columns);
                    for (int i = 1; i <= columns; i++)
                        row.addElement( rs.getObject(i) );
                    data.addElement( row );
                rs.close();
                stmt.close();
            catch(Exception e)
                System.out.println( e );
            //  Create table with database data
            JTable table = new JTable(data, columnNames);
            jPanel2.setLayout(new java.awt.BorderLayout());
            jPanel2.add(table, BorderLayout.CENTER);I know its a bit messy, wat im tryin to do is add the table to the panel. the rows are showing perfectly but the column names do not show! Can anyone help?

    1) Please ask Swing questions in the Swing forum.
    2) Don't forget to specifically make the table header display. You do this by adding the table header to the jpanel in the borderlayout NORTH position, and you get the table header by calling getTableHeader. Have a look here for instance:
    http://forum.java.sun.com/thread.jspa?threadID=5235339&tstart=0

  • JTable Column Names Not Displaying

    Hi there
    I create a JTable by passing the JTable constructor my custom TableModel which extends AbstractTableModel.
    For column names I have a String[] containing the column names in my custom TavleModel and have coded the TableModel methods accordingly.
    For some reason when I run the code the table is displayed, but the column names are not!?!
    Any advance is appreciated!

    Sorted!
    After looking at sample code in the JTable tutorial, it seems the table likes/needs to be added to a JScrollPane, as once I did this the column headings started appearing.
    e.g. JScrollPane scrollPane = new JScrollPane(table);

  • APEX 4.0 "Use Generic Column Names" not working

    Hi,
    I have a report which is a SQL query (PL/SQL function body returning SQL query) in APEX 4.0. For this region i have selected the option "Use Generic Column Names (parse query at run time only)".
    For some reason when I run the page the browser just shows the error "The requested URL /apex/f was not found on this server". This happens only for the region type "SQL query (PL/SQL function body returning SQL query)" . If I choose the report region as SQL query and select the option "Use Generic Column Names (parse query at run time only)" That works fine. This happens only in APEX 4. Is it an apex 4 bug or am I missing something?
    Thanks
    Sashika.

    Hi,
    Just managed to get it running. The Apex 4.0 SQL query (PL/SQL function returning SQL) works just fine. I had a small error in the query itself. In the PL/SQL function I had a referenced page item whose value in the initial run is set to null which is making the fuzz. Just adding an NVL resolved the problem.

  • Column names not visible in JTable

    Hello everyone,
    i have an Object array columns that i pass to the constructor of JTable, but for some reason the column names are not visible in my table.
    private final Object[] columns = {"Zeit", "Termin"};
    private Object[][] rows;
    //the next line fills the two-dimensional rows-array
    fillRows();
    //here the constructor
    JTable table = new JTable(rows, columns);
    table.setColumnSelectionAllowed(false);
    table.setDragEnabled(false);
              table.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    TableColumnModel colModel = table.getColumnModel();
    TableColumn column = colModel.getColumn(1);
    column.setCellRenderer(new BookedCellRenderer(new int[] {3,4}));What are possible reasons/sollutions for this problem?

    Gosh, thanks! Usually i always use a jscrollpane for
    jtables and was about to use it too, but i got
    confused because of the headers when i tried to see
    whether the data in the table was right.You're welcome. The JTableHeaders object can be displayed in, say,
    the NORTH part of a BorderLayout while the JTable itself is displayed
    int the CENTER part. You can even display the headers SOUTH of
    the table itself if you like. A JTable object is quite flexible.
    kind regards,
    Jos

  • Table column names not getting displayed

    Hi
    When i do a SELECT statement i am not getting the column names
    SQL> SELECT * FROM EE;
    aa physics 100
    bb physics 200
    PLease let me know how can i set it.
    Thank you
    Marium Thomas

    Did you modify some of the default settings (e.g. HEADING or PAGESIZE)?
    Try
    set heading onhttp://download-uk.oracle.com/docs/cd/B10501_01/server.920/a90842/ch13.htm#1011230

  • Column Name not displaying in WinXP

    Hi,
    I have a custom JTable that has the contructor :
    public CustomMatrixTable(TableModel dm)
    super(dm);
    setAutoCreateColumnsFromModel(true);
    setColumnSelectionAllowed(true);
    setRowSelectionAllowed(true);
    setCellSelectionEnabled(true);
    setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    The table model has overrides the getColumnName by retriving the name from a Vector.
    There are two coulmns in my example but the number can vary.
    In Windows 2000 it work perfectly. In XP the first column's name can be displayed but not the next.
    In fact the column header does not appear.
    please help.
    thanks
    Phill

    ok, it would seem that the work around is to declare a TableCellRenderer to be assigned as the column's header renderer. Unfortunately I have to do it for each column, nice if you want to make colourful column headers, but really one should be able to assign the column header renderer to be used by all column headers.

  • 2 items: 1) importing cvs columns do not match t-bird columns 2) error msg when trying to add 2nd email account

    Hi and thanks in advance for lending a hand.
    Issue #1
    Followed instructions at https://www.youtube.com/watch?v=8Df8mRL3TBs to import cvs to t-bird – but
    My cvs headings are not name, email m chat name, org, additional email etc etc
    Why are my columns names not showing up?
    +++++++++++++++++++++++++++++++++++
    Issues #2
    Adding second email address in thunder bird
    email address #1 works fine - but trying to add 2nd one – having error msgs poop up.
    1st error msg is:
    [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIMsgIncomingServer.verifyLogon]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: chrome://messenger/content/accountcreation/verifyConfig.js :: verifyLogon :: line 98" data: no]
    Pressing “done" again yields different error reply: Incoming server already exists.
    [end of error msgs]
    Have tried box1121.bluehost.com as well as mail.bikempowered.com for server hostnames - various ports and SSL’s
    The Tech at blue host claimed there this was a bug known to thunderbird – and that a solution is known to be needed.
    Seeking solutions - also I’m 90% Luddite - so please if at all possible, but things in “for Dummies” mode
    With gratitude and hope,
    Brian

    About .csv check your .csv-file as a text file.
    Is the first line your column-names separated with a "," ?
    It should be. When you import, mark that 1st line has column-names
    Then move Tbird's names around until they correspond with yours. Your names will not be imported.

  • Rowset column name problem

    All,
    I am a new user of JSC and am hopefully running into a simple issue. I've searched the forums here but so far have not found any postings regarding my problem. Apologies if this has been asked and answered before.
    I am building a webapp to display data from a MySQL database. There are several places in the schema where I need to join to the same table multiple times. I have setup the joins in the query builder and also setup a view in the database directly that does the joins. Either way, the query works fine and returns the expected data. The trouble is that the rowset underlying the dataprovider is not returning the metadata using either the table&column aliases from the query builder or the column names from the view, but rather in all cases returning the underlying table and column names. In my table component I am trying to display the data from each table.column alias distinctly but because the metadata visible to the dataprovider is the same (ie table.column), I end up with both table columns showing the same data. I've tried to track down the implementation of the metadata getter method but it is apparently in source that is not provided.
    In case it matters, I'm using mysql-connector-java-5.0.3-bin.jar as the driver.
    Is there something I'm missing or is there a workaround for this?
    Thanks in advance,
    Scott

    Thanks,
    I should have been more explicit in my description of the problem.
    Example of what I have is as follows:
    select table1.columnA, table2.columnA as columnX,....
    from table_name as table1 join table_name as table2....
    where there are other tables and columns in the select clause as well as the join conditions but where the base table and column (in the above table_name.columnA) are used twice with two different aliases. I have done this join directly in the query builder and also created a view, hiding the actual names of the columns. I can execute either query in the query builder and the columns in the result set "spreadsheet" are labeled with the base table column names, not the aliased names or the view's column names. This is causing a problem because the same thing happens when I try to bind the ui:table columns to the dataprovider. It uses the base tables' column names and I have no way to distinguish between the different aliases. If I try to manually change the jsp to refer to the aliased name or the view column name, I get an exception that the aliased tablename and or column is an invalid parameter.
    Sorry if that was not clear in my original post.

  • Problem in XI - JDBC (oracle) Scenario, case sensitive column name

    I had a XI -> JDBC scenario, connecting to a SQL server, where the query was being generated using Message Mapping (XML SQL Format),
    now the database has been migrated from SQL server to Oracle, and we are using the same XI scenario, but now the problem is, the query generated using message mapping doesnt work because it seems the query (UPDATE statement) requires the field name as having All capital letters, i mean the Column name in query to Oracle has become case sensitive,
    can u help me out

    Hi
    Oracle doesnt have restriction that Query has to be in uppercase for any column. But it is good go use Upper case for the Query.
    Use oracle editor to do the query if it is working fine and then use XML SQL in XI
    Check this thread SAP has given some
    http://help.sap.com/saphelp_nw04s/helpdata/en/43/68a541a1166153e10000000a1553f6/frameset.htm
    Check FAQ on the JDBC adapter, see SAP Note 831162
    always useful Note
    Thanks
    Gaurav

  • JDBC send data to oracle, oracle only accept column name in Upper case

    Hi experts,
    I am doing a scenario File --> XI --> JDBC,  JDBC send data to a Oracle 10g database, I have configured JDBC receiver to use XML-SQL format. in oracle database ,  table "EMPLOYEE" has a column "NAME", but when I send data to oracle using JDBC receiver, the column is "name", then XI complains
    " 'EMPLOYEE' (structure 'insert'): java.sql.SQLException: FATAL ERROR: Column 'name' does not exist in table 'EMPLOYEE'.
    can anyone help me to let oracle accpet column "name". I can't change colum in JDBC receiver from "name" to "NAME".
    Thanks a lot.

    <i>can anyone help me to let oracle accpet column "name"</i>
    Making Oracle case insensitive is not possible (in my opinion). By default all object names are stored in UPPER case in the rdbms dictionary.
    When XI searches for column name in Oracle, this search is case sensitive. So u have to configure accordingly.
    Regards,
    Prateek

Maybe you are looking for

  • Having trouble networking my G5 running 10.5 and my G4 running 10.2

    I used to be able to connect my machines using my home router/network.  I recently updated my G5 from Tiger to Leopard.  When i was still running Tiger i had no problem connecting with my network.  My G5 still shows up on the G4 but as an allias, and

  • Where clause on one column out of two

    I have a where clause filtering out data from the sum(workhour) column. I want to return another column beside it that does not filter workhour and a third column that filters workhour based on a different criteria. Is this possible? sql select activ

  • Business Area display in Tcode FAGLB03

    Dear Friends, We have ECC6 upgraded from April 2011. In FS10N we have business area tab appearing whereas when we use FAGLB03 the same is not appearing either as selection or when executing a G/L. Can this be resolved by applying the support package

  • Infotype update on claim request status

    Hi, I have one scenario where I have to update a z infotype on & every processing status for claim request. The processing status gets changes on creation & approval process through workflow. I am using the standard workflow for claim & reimbursement

  • ReInstall Final Cut Server

    Hi, I would like to Uninstall Final Cut Server, so I can install it myself, Can anyone help?