>> The solution you propose would involve would establish a connection for 
each query? I'd imagine that would not perform too well.

I agree that it would not perform too well to establish a new connection at 
each query.  Instead, I plan on using "long-lived" jdbc connections.  At a 
client's first http query, it creates a JDBC connection, if successful, it 
adds that connection to a map and keeps it "alive".  Every so often the 
connection is refreshed, and unused connections are reaped by a background 
thread.

>>I suggest establishing a connection once with one API call, which returns 
a token. Then use that token with future queries instead of supplying the 
credentials with each API call.

That is a good idea bout the token, but I am thinking about doing the 
following:  I suggest requiring the user/pass at each request (which makes 
each request the same format), and I grab the long-lived connection from 
the map keyed to String(userName+pass+ipadress).  This way a partciular 
client will aways get his connection back (assuming it has not been 
refreshed or reaped), and even if a different client uses the same username 
and password, they will still have their own connections (because the map 
of connection is keyed also to the client's ip address).  In short: the 
http server maintains a set of connection pools (with default size of 1) 
for each client that connects, and it reaps the connections periodically.

>> Maybe this project is what you are looking for
>>https://github.com/bjornharrtell/jdbc-http-server

This is interesting, thanks for sharing it.  But, there are a few 
limitations to that project (if I understand it correctly)
1.  It does not use standard "raw" sql for select/updates/insert/etc. 
 Instead, it uses a custom url (parameter based) format that, while being 
very REST-like, is non standard.
2.  According to the doc, the non-standard format can't handle more complex 
queries
3.  Does not take advantage of prepared statements.

Instead, I suggest a format that uses normal sql and allows prepared 
statements, which is delivered via a json string in the HTTP post, example:

{
    user: 'dbUserName',
    pass: 'password',
    sql: "select * from users where name=? AND isIdiot=?",
    params: ['Adam', true]
}



returns the result, something like:

[
{
    name: "Adam",
    isIdiot: true,
    country: "USA",
    language: "English"
}
]




On Friday, February 24, 2017 at 7:04:20 AM UTC-5, Manfred Rosenboom wrote:
>
> Maybe this project is what you are looking for
>
> https://github.com/bjornharrtell/jdbc-http-server
>
> Best,
> Manfred
>

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to h2-database+unsubscr...@googlegroups.com.
To post to this group, send email to h2-database@googlegroups.com.
Visit this group at https://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.

Reply via email to