java -Dhttp.agent="Mozilla/4.0 (compatible;
MSIE 6.0; Windows NT 5.0)" -jar my.jar

(the quotes must be only around the argument)

For the Streamhandler you can try this:
URL.setURLStreamHandlerFactory(new URLStreamHandlerFactory() {

                @Override
                public URLStreamHandler createURLStreamHandler(String protocol) 
{
                        if (protocol.equalsIgnoreCase("httpwithagent")) {
                                return new URLStreamHandler() {
                                        @Override
                                        protected URLConnection 
openConnection(URL u) throws IOException {
                                                URL httpurl = new URL("http", 
u.getHost(), u.getPort(), u.getFile(),
                                                                null);
                                                URLConnection connection = 
httpurl.openConnection();
                                                
connection.setRequestProperty("User-Agent",
                                                                "Mozilla/4.0 
(compatible;  MSIE6.0; Windows NT 5.0)");
                                                return connection;
                                        }
                                };
                        }
                        return null;
                }
        });
                
                CREATE TABLE RAWDATA (`HTML` CLOB );
                INSERT INTO
                    RAWDATA
                    (HTML)
                VALUES
                    (SELECT
                        
FILE_READ('httpwithagent://www.google.de/search?q=H2+database',
                        NULL));




Am 21.02.2012 10:48, schrieb Dani:
Hey there,

I tried:

- commandline parameters: java "-Dhttp.agent=Mozilla/4.0 (compatible;
MSIE 6.0; Windows NT 5.0)" -jar my.jar
- System.setProperty ("http.agent", "Mozilla/4.0 (compatible;MSIE 6.0;
Windows NT 5.0)");

the only thing that does work for me is:

- not using H2 - FILE_READ but a buffered reader with:
   conn.setRequestProperty ( "User-Agent", "Mozilla/4.0 (compatible;
MSIE6.0; Windows NT 5.0)" );
   and save the data locally to disc ->  then executing a FILE_READ :-(

this does not work (e.g. H2 Console):

DROP TABLE IF EXISTS RAWDATA;
CREATE TABLE RAWDATA (`HTML` CLOB );
INSERT INTO
     RAWDATA
     (HTML)
VALUES
     (SELECT
         FILE_READ('http://www.google.de/search?q=H2+database',
         NULL));

I do not know if it is only my system!?
But it would be nice to have a FILE_READ / CSV_READ parameter 'User-
Agent' for urls

Thanks again,
Dani

On 13 Feb., 20:05, Thomas Mueller<[email protected]>
wrote:
Hi,

What do you mean:
(start with java -d*http.agent*="myAgent" ....)
commandline? as a param with conn url org:h2 ?
No, command line (terminal, console, shell) or starting a process.

How would I do that on startup with my program?
java -Dhttp.agent="myAgent" -jar yourApplication.jar

Regards,
Thomas

--
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

Reply via email to