Solved

Saving QueryDataSet Result to the File ....

Posted on 2004-10-14
16
244 Views
Last Modified: 2008-02-26
I am trying to save QueryDataSet result to file, by reading data column by column and row by row, but as I do not know the data type of column how to save data to the file.

Thanks & Regards,
0
Comment
Question by:smartvanl5
  • 4
  • 4
  • 4
  • +1
16 Comments
 
LVL 3

Expert Comment

by:RuadRauFlessa
ID: 12305745
Try retrieving the Metadata of the data set if there is any.
0
 

Author Comment

by:smartvanl5
ID: 12305903
How to get the DataType of the Column.
0
 
LVL 35

Expert Comment

by:TimYates
ID: 12306049
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:smartvanl5
ID: 12306293
I still unable to solve my problem, As I am new in JAVA.

I am requesting you Send me code which SAVE QueryDataSet result in the file.

Please ...
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 25 total points
ID: 12306346
Most columns will come out properly, without knowing the type:

PrintWriter out = new PrintWriter(new FileWriter("results.txt"));
while (resultSet.hasNext()) {
      out.print(resultSet.getObject("col1"));
      out.print(resultSet.getObject("col2"));
      out.print(resultSet.getObject("col3"));
      out.println();
}
resultSet.close();
out.close();
0
 
LVL 35

Expert Comment

by:TimYates
ID: 12306399
> I am requesting you Send me code which SAVE QueryDataSet result in the file.

What code do you have already?  Any of it?
0
 

Author Comment

by:smartvanl5
ID: 12306468
   try {
      QueryDataSet DashBoard = new QueryDataSet();
      WorkbookSettings ws = new WorkbookSettings();
      ws.setLocale(new Locale("en", "EN"));
      workbook = Workbook.createWorkbook(new File("c:/igmoutput/query.xls"), ws);
      WritableSheet sheet = workbook.createSheet("Result", 0);
      //Label label = new Label(Column, Row, "A lable record");
      int iCurrentColumn = 0;
      int iCurrentRow = 0;
      while (DashBoard.columnCount() > iCurrentColumn) {
        Label label = new Label(iCurrentColumn, iCurrentRow, DashBoard.getString(0));
        sheet.addCell(label);
        iCurrentColumn = iCurrentColumn + 1;
      }
      iCurrentRow = iCurrentRow + 1;
      while (DashBoard.inBounds()) {
        iCurrentColumn = 0;
        while (DashBoard.columnCount() > iCurrentColumn) {
          Label label = new Label(iCurrentColumn, iCurrentRow, DashBoard.getString(0));
          sheet.addCell(label);
          iCurrentColumn = iCurrentColumn + 1;
        }
        DashBoard.next();
        iCurrentRow = iCurrentRow + 1;
      }
      workbook.write();
      workbook.close();
    } catch (Throwable t) {
      System.out.println(t.toString());
      t.printStackTrace();
    }


Label label = new Label(iCurrentColumn, iCurrentRow, DashBoard.getString(0));

As I am getting the column data, I do not know column data type.

0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12306586
smartvanl5, do you see what's happened here? Everyone has assumed you're talking about the Java API, but you're not - you're talking about some proprietary API. Unless you have a very good reason for using this, it would be better if you don't, as you'll find it much easier to get support and your code will be much more portable (as well as your accumulated knowledge).

I haven't even been able to find the docs online for QueryDataSet.
0
 

Author Comment

by:smartvanl5
ID: 12306667
Sorry for inconviance,

I am using JBuilder8 for development so QueryDataSet is part of it.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12306704
Well, the question can probably only be answered by fellow JBuilder users then i'm afraid since the docs for that class don't seem to be publicly available
0
 
LVL 35

Assisted Solution

by:TimYates
TimYates earned 25 total points
ID: 12306791
getColumn( int pos ).getSqlType()

should do it...
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12306840
Despite the fact this is not a normal ResultSet, my earlier comment about it not being necessary to know the type will probably still hold
0
 
LVL 35

Expert Comment

by:TimYates
ID: 12306910
Yeah, it does :-)  (I think)...  you can call "getObject", but I have no way of knowing what the response is, as I have never used this class in my life...  I'm a JDBC man myself ;-)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
xampp tool 12 56
Opening PDF on button click and fill new document 2 47
by zero exception 10 52
Android development question 2 54
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question