[DBUTILS] BeanHandler plus Blob

2010-10-15 Thread Manuel
Hi,

have a class

public class Person {
  private Blob image;
  public void setImage(Blob image) { this.image = image; }
  public Blob getImage() { return image; }
}

Now I want to load the Person-class with BeanHandler-class
ResultSetHandlerPerson h = new BeanHandlerPerson(Person.class);
Person person = runner.query(select image from ..., h);

Works so far :-) Now what not works:

person.getImage();
ObjectInputStream ois = null;
ois = new ObjectInputStream(blob.getBinaryStream());
ImageIcon icon = (ImageIcon) ois.readObject();

- Exception
You cannot invoke other java.sql.Clob/java.sql.Blob methods after calling
the free() method or after the Blob/Clob's transaction has been committed
or rolled back.

Do the query myself, or and write a own BeanHandler...
But shouldn't there a solution to just say
1.) write blob data in a stream x
2.) write blob data to an object x

OR ... go the other way, means change Person class to have an object let's
say instead Blob and ImageIcon and tell dbutils how to map from blob to
ImageIcon...

thanks for any response in advance ;)

greetings manuel


-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: when use FTPClient to do server to server file transfer's append failed

2010-10-15 Thread sebb
On 15 October 2010 02:00, chenxuejie chen_xue...@nec.cn wrote:
 Hi all

 The action is server to which the client is connected to append to a given
 file on the other server
 The result is the new file replaced the remote file.

 I think FTPClient.java  should change as follows:

 public boolean remoteAppend(String filename) throws IOException
    {
        if (__dataConnectionMode == ACTIVE_REMOTE_DATA_CONNECTION_MODE ||
                __dataConnectionMode == PASSIVE_REMOTE_DATA_CONNECTION_MODE)

 //            return FTPReply.isPositivePreliminary(stor(filename));
            return FTPReply.isPositivePreliminary(appe(filename));
        return false;
    }

 thanks

Thanks for the report; the code will be changed as you suggest.

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: when use FTPClient to do server to server file transfer's append failed

2010-10-15 Thread sebb
On 15 October 2010 09:53, sebb seb...@gmail.com wrote:
 On 15 October 2010 02:00, chenxuejie chen_xue...@nec.cn wrote:
 Hi all

 The action is server to which the client is connected to append to a given
 file on the other server
 The result is the new file replaced the remote file.

 I think FTPClient.java  should change as follows:

 public boolean remoteAppend(String filename) throws IOException
    {
        if (__dataConnectionMode == ACTIVE_REMOTE_DATA_CONNECTION_MODE ||
                __dataConnectionMode == PASSIVE_REMOTE_DATA_CONNECTION_MODE)

 //            return FTPReply.isPositivePreliminary(stor(filename));
            return FTPReply.isPositivePreliminary(appe(filename));
        return false;
    }

 thanks

 Thanks for the report; the code will be changed as you suggest.


I created the following JIRA issue to track this:

https://issues.apache.org/jira/browse/NET-341

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



RE: How can I get Commons-net-2.1 Source and Binaries

2010-10-15 Thread Jörg Schaible
陳雪傑 wrote:

 
 Hi Jörg
  
 
 You cannot, since it was never officially released. So, yes,
 there is a tag in Subversion, but nobody knows, who spread it
 into public, what it actually contains and you're on your own
 using this code. Therefore you cannot download any binaries
 or tar balls, it has no direct support here. Actually you
 should use version 2.0 until we release the next version
 which will be 2.2.
 
 Do you know the version 2.2 release date?

No, sorry. Does 2.0 not work for you?

- Jörg


-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Commons Upload: Can not read parameters if input type file is empty ...

2010-10-15 Thread michael . laube
Hello developers, 

i try to use the upload function. I use a form with a text Field, a 
Textare and some checkoxs and an input Type of file. If write somthing in 
these fields and choose a file to upload the behavior is good. The Upload 
will be executed. When i write only somthing to the other input elements 
(file choose is empty) I get an exception like this: 

Processing of multipart/form-data request failed. Stream ended 
unexpectedly 

This happens only if no file is choosen. Only the values of the other 
fields will be submitted.  This Part of code throw the exception. 

items = upload.parseRequest(request); 

Perhaps i make somthing wrong ... 

Perhaps it is a bug  

I don't now  



Best regards 

Michael Laube 

 
 


Source of the form: 


form  action=/xxx/CentralControl method=post class=admin enctype=
multipart/form-data 
 
fieldset class=admin 
legendNews/legend 
label class=adminUuml;berschrift:/label 
input type=text name=ueberschrift value=
${hN.ueberschrift} size=68/br/ 
label class=adminInhalt/label 
textarea class=admin name=neuigkeit rows=30 
cols=60${hN.text_aktuelles}/textarea 
 
 
 
 
   label class=adminDatei hochladen:/label
INPUT name=userfile1 type=file/ 


 
 
 
 
 
label class=adminPublizieren/label 
 
%if(hN.getVeroeffentlich_status()!=null){ % 
input type=checkbox class=admin name=
publizieren value=1 checked=checked/br/ 
%} 
else{ 
% 
input type=checkbox class=admin name=
publizieren value=1 /br/ 
%} % 
 
 
 
label class=adminNews Bw /label 
 
%if(hN.getNewsbw()!=null){ % 
input type=checkbox class=admin name=newsbw 
value=1 checked=checked/ 
%} 
else{ 
% 
input type=checkbox class=admin name=newsbw 
value=1/ 
%} % 
 
label class=adminNews UAN/label 
 
%if(hN.getNewsuan()!=null){ % 
input type=checkbox class=admin name=
newsuan value=1 checked=checked/ 
%}else{ % 
input type=checkbox class=admin name=
newsuan value=1/ 
%} % 
 
 
label class=adminLöschkennzeichen: /label 
%if(hN.getLoeschkennzeichen()!=null){ % 
input type=checkbox class=admin name=
loeschkennzeichen value=1 checked=checked/ 
%}else{ % 
input type=checkbox class=admin name=
loeschkennzeichen value=1 / 
%} % 
 
 
label class=adminE-Mail Nachricht: /label 
input type=checkbox class=admin name=
newsuansendmail value=1/ 
 
input type=hidden name=hiddenNewsId value=
${hN.id} / 
/fieldset 
fieldset class=button 
input type=hidden name=servletName value=
saveNews/ 
input type=hidden name=jsessionid value=%=
session.getId()%/ 
input type=submit name=sendIt value=
Speichern/ 
/fieldset 
/form 

Source of Servlet Logic: 

System.out.println(Multi Form Data Parameter auslesen ---:); 
PrintWriter pw = response.getWriter();   
String n=;String v=;   
 
 
FileItemFactory   factory = new 
DiskFileItemFactory(); 



 
 
ServletFileUpload upload = new 
ServletFileUpload(factory);   
upload.setFileSizeMax(5000); 
upload.setSizeMax(-1); 


List items = null;   
 
try {   
 
items = upload.parseRequest(request); 
 
 
} 
catch (FileUploadException e) {   
System.out.println(e.getMessage()); 
System.out.println(Exception:-) 
-); 
} 
if(items!=null){ 
System.out.println(Nach Try Upload ... 
---); 
 
Iterator itr = items.iterator();   
 
 
while (itr.hasNext()) {   
FileItem item = (FileItem) itr.next();   
 
if (item.isFormField()){   
n=item.getFieldName();   

Re: [Math] Exponential curve fitting problem

2010-10-15 Thread Christiaan

Thanks for the provided info! If I understand it correctly, then in order to
apply the least square method for regression analysis the data should be
mapped to a linear model in order to get better results? Converting the data
to ln y indeed gives better results, but is still not a perfect fit like I
have for instance with polynomial functions. Are there other methods
available for curve fitting which don't have this requirement?

regards,
Christiaan
-- 
View this message in context: 
http://apache-commons.680414.n4.nabble.com/Math-Exponential-curve-fitting-problem-tp2995629p2996928.html
Sent from the Commons - User mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: Commons Upload: Can not read parameters if input type file is empty ...

2010-10-15 Thread Jason Britton
Before you call parseRequest I would first check to make sure you're
dealing with a multipart post - in cases when you're not uploading a
file calling parseRequest may not be the right way to go and that
exception being thrown is FileUpload's way of telling you, hey I don't
see any file data to handle thus the  Stream ended unexpectedly.
That's my best guess.  Try something like this

// Check that we have a file upload request
boolean isMultipart = ServletFileUpload.isMultipartContent(request);

if (isMultipart) {
// do your parseRequest here since you know they uploaded a file
} else {
// no file uploaded this time, try retrieving non-file form
parameter values old fashioned way, request.getParameter(foo) etc...
}

// operate on retrieved form data here

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: Commons Upload: Can not read parameters if input type file is empty ...

2010-10-15 Thread Brian Pontarelli
The code and HTML look good. I've gotten that message a number of times and 
what it generally means is that the request body isn't properly formatted. More 
specifically, when the MultipartStream is asking the underlying stream (in this 
case the ServletInputStream) for more bytes it returns -1 signifying the end of 
the body.

Is anything else touching the InputStream before your code does? That could 
cause issues.

Another thing I would try is to read in the request body and output to stdout. 
This will help you determine if it looks like properly formatted multipart 
body. You could also post that output to the list and we can take a look as 
well.

-bp


On Oct 15, 2010, at 4:38 AM, michael.la...@hilgmbh.de wrote:

 Hello developers, 
 
 i try to use the upload function. I use a form with a text Field, a 
 Textare and some checkoxs and an input Type of file. If write somthing in 
 these fields and choose a file to upload the behavior is good. The Upload 
 will be executed. When i write only somthing to the other input elements 
 (file choose is empty) I get an exception like this: 
 
 Processing of multipart/form-data request failed. Stream ended 
 unexpectedly 
 
 This happens only if no file is choosen. Only the values of the other 
 fields will be submitted.  This Part of code throw the exception. 
 
 items = upload.parseRequest(request); 
 
 Perhaps i make somthing wrong ... 
 
 Perhaps it is a bug  
 
 I don't now  
 
 
 
 Best regards 
 
 Michael Laube 
 
 
 
 
 
 Source of the form: 
 
 
 form  action=/xxx/CentralControl method=post class=admin enctype=
 multipart/form-data 
 
fieldset class=admin 
legendNews/legend 
label class=adminUuml;berschrift:/label 
input type=text name=ueberschrift value=
 ${hN.ueberschrift} size=68/br/ 
label class=adminInhalt/label 
textarea class=admin name=neuigkeit rows=30 
 cols=60${hN.text_aktuelles}/textarea 
 
 
 
 
   label class=adminDatei hochladen:/label
 INPUT name=userfile1 type=file/ 
 
 
 
 
 
 
 
label class=adminPublizieren/label 
 
%if(hN.getVeroeffentlich_status()!=null){ % 
input type=checkbox class=admin name=
 publizieren value=1 checked=checked/br/ 
%} 
else{ 
% 
input type=checkbox class=admin name=
 publizieren value=1 /br/ 
%} % 
 
 
 
label class=adminNews Bw /label 
 
%if(hN.getNewsbw()!=null){ % 
input type=checkbox class=admin name=newsbw 
 value=1 checked=checked/ 
%} 
else{ 
% 
input type=checkbox class=admin name=newsbw 
 value=1/ 
%} % 
 
label class=adminNews UAN/label 
 
%if(hN.getNewsuan()!=null){ % 
input type=checkbox class=admin name=
 newsuan value=1 checked=checked/ 
%}else{ % 
input type=checkbox class=admin name=
 newsuan value=1/ 
%} % 
 
 
label class=adminLöschkennzeichen: /label 
%if(hN.getLoeschkennzeichen()!=null){ % 
input type=checkbox class=admin name=
 loeschkennzeichen value=1 checked=checked/ 
%}else{ % 
input type=checkbox class=admin name=
 loeschkennzeichen value=1 / 
%} % 
 
 
label class=adminE-Mail Nachricht: /label 
input type=checkbox class=admin name=
 newsuansendmail value=1/ 
 
input type=hidden name=hiddenNewsId value=
 ${hN.id} / 
/fieldset 
fieldset class=button 
input type=hidden name=servletName value=
 saveNews/ 
input type=hidden name=jsessionid value=%=
 session.getId()%/ 
input type=submit name=sendIt value=
 Speichern/ 
/fieldset 
 /form 
 
 Source of Servlet Logic: 
 
 System.out.println(Multi Form Data Parameter auslesen ---:); 
PrintWriter pw = response.getWriter();   
String n=;String v=;   
 
 
FileItemFactory   factory = new 
 DiskFileItemFactory(); 
 
 
 
 
 
ServletFileUpload upload = new 
 ServletFileUpload(factory);   
upload.setFileSizeMax(5000); 
upload.setSizeMax(-1); 
 
 
List items = null;   
 
try {   
 
items = 

[configuration] ini files containing only a global section supported by HierarchicalINIConfiguration?

2010-10-15 Thread Andre Weihe
Are ini files containing only a global section allowed to be used with commons 
configuration, especially the HierachicalINIConfiguration class?

I found no advice in the javadocs that ini files should contain more than just 
a global section but it seems HierachicalINIConfiguration can read those files 
just fine but is not able to save them.

This is due to HierachicalINIConfiguration#getSections() can't really deal with 
those files.

The current code:
Set sections = new ListOrderedSet();
boolean globalSection = false;

for (Iterator it = getRootNode().getChildren().iterator(); 
it.hasNext();)
{
ConfigurationNode node = (ConfigurationNode) it.next();
if (isSectionNode(node))
{
if (globalSection)
{
sections.add(null);
globalSection = false;
}
sections.add(node.getName());
}
else
{
globalSection = true;
}
}

return sections;


This code only acknowledges a global section when at least one other named 
section is present.

HierachicalINIConfiguration#save() call this functions and only saves sections 
returned by getSections() so if there is only a global section and no other 
sections nothing gets saved.

Is this on purpose or could getSections() be changed to something like this?:

Set sections = new ListOrderedSet();

for (Iterator it = getRootNode().getChildren().iterator(); 
it.hasNext();)
{
ConfigurationNode node = (ConfigurationNode) it.next();
if (isSectionNode(node))
{
sections.add(node.getName());
}
else
{
sections.add(null);
}
}

return sections;

-- 
André WeiheZengel Medizintechnik GmbH

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [configuration] ini files containing only a global section supported by HierarchicalINIConfiguration?

2010-10-15 Thread Oliver Heger

Hi Andre,

Am 15.10.2010 17:49, schrieb Andre Weihe:

Are ini files containing only a global section allowed to be used with commons 
configuration, especially the HierachicalINIConfiguration class?

I found no advice in the javadocs that ini files should contain more than just 
a global section but it seems HierachicalINIConfiguration can read those files 
just fine but is not able to save them.

This is due to HierachicalINIConfiguration#getSections() can't really deal with 
those files.

The current code:
 Set sections = new ListOrderedSet();
 boolean globalSection = false;

 for (Iterator it = getRootNode().getChildren().iterator(); 
it.hasNext();)
 {
 ConfigurationNode node = (ConfigurationNode) it.next();
 if (isSectionNode(node))
 {
 if (globalSection)
 {
 sections.add(null);
 globalSection = false;
 }
 sections.add(node.getName());
 }
 else
 {
 globalSection = true;
 }
 }

 return sections;


This code only acknowledges a global section when at least one other named 
section is present.

HierachicalINIConfiguration#save() call this functions and only saves sections 
returned by getSections() so if there is only a global section and no other 
sections nothing gets saved.

Is this on purpose or could getSections() be changed to something like this?:

 Set sections = new ListOrderedSet();

 for (Iterator it = getRootNode().getChildren().iterator(); 
it.hasNext();)
 {
 ConfigurationNode node = (ConfigurationNode) it.next();
 if (isSectionNode(node))
 {
 sections.add(node.getName());
 }
 else
 {
 sections.add(null);
 }
 }

 return sections;



This behavior is surely not by intention. With other words: it is a bug. 
Could you please file a bug report in our tracking system [1], so that 
this issue won't get lost.


Thanks.
Oliver

[1] http://commons.apache.org/configuration/issue-tracking.html

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



AW: [configuration] ini files containing only a global section supported by HierarchicalINIConfiguration?

2010-10-15 Thread Andre Weihe
Von: Oliver Heger [mailto:oliver.he...@oliver-heger.de]

[Description of current behaviour and proposed fix]

This behavior is surely not by intention. With other words: it is a bug.
Could you please file a bug report in our tracking system [1], so that
this issue won't get lost.

Filed as https://issues.apache.org/jira/browse/CONFIGURATION-424

Set priority to Critical because of the potential data loss.

The bug is AFAIK still present in the HEAD version in the SVN as I checked some 
hours before but I don't know since when it's present.
https://issues.apache.org/jira/browse/CONFIGURATION-325 reports a similar bug 
in the deprecated INIConfiguration that was supposed to be fixed in the 
HierarchicalINIConfiguration so I guess this is when the bug crept in. 

-- 
André WeiheZengel Medizintechnik GmbH



-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [DBUTILS] BeanHandler plus Blob

2010-10-15 Thread Manuel
Hi,

just if some else have similar problem... found the solution myself.

Overwrite BeanProcessor

public class MyBeanProcessor extends BeanProcessor {
  @Override
  rotected Object processColumn(ResultSet rs, int index, Class?
propType) throws SQLException {
if (propType.equals(ImageIcon.class)) {
  return getImageIcon(rs.getBlob(index));
}

return super.processColumn(rs, index, propType);
  }
}

Create ResultSetHandler like that:

ResultSetHandlerPerson h = new BeanHandlerPerson(Person.class, new
BasicRowProcessor(new MyBeanProcessor()));

That would do the job, now you can map a blob to an ImageIcon.
You can implement other special type the same way!

Greetings Manuel


Am Fr, 15.10.2010, 09:06 schrieb Manuel:
 Hi,

 have a class

 public class Person {
   private Blob image;
   public void setImage(Blob image) { this.image = image; }
   public Blob getImage() { return image; }
 }

 Now I want to load the Person-class with BeanHandler-class
 ResultSetHandlerPerson h = new BeanHandlerPerson(Person.class);
 Person person = runner.query(select image from ..., h);

 Works so far :-) Now what not works:

 person.getImage();
 ObjectInputStream ois = null;
 ois = new ObjectInputStream(blob.getBinaryStream());
 ImageIcon icon = (ImageIcon) ois.readObject();

 - Exception
 You cannot invoke other java.sql.Clob/java.sql.Blob methods after calling
 the free() method or after the Blob/Clob's transaction has been committed
 or rolled back.

 Do the query myself, or and write a own BeanHandler...
 But shouldn't there a solution to just say
 1.) write blob data in a stream x
 2.) write blob data to an object x

 OR ... go the other way, means change Person class to have an object let's
 say instead Blob and ImageIcon and tell dbutils how to map from blob to
 ImageIcon...

 thanks for any response in advance ;)

 greetings manuel




-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org