Обсуждение: Swing and JDBC

Поиск
Список
Период
Сортировка

Swing and JDBC

От
"Dennis R. Gesker"
Дата:
Could someone on this list point me toward a simple but illustrative
application built in Swing that uses JDBC (perferrably Postgres JDBC).

I've been using the JDBC driver on Apache/Tomcat/Linux to generate web
reports reading records from postgres and it has been working great.

Now I'm considering reworking our database applications (currently in
MS-Access) using Java but I'm looking for a small application that uses
Swing & JDBC that can give me an idea of the best practices using these
2 different parts of the API together. I of course intend to use
Postgres for the back end but I think that the Java would be the way to
go for the front end.

I've found alot of examples for either Swing or JDBC sepearately but
none showing them together and working efficiently. I expect my
application will have to support about 20 concurrent users but the
structure of the database tables will only require a few tables and some
relatively simple relationships.

Sorry in advance if this is too far off topic but I always seem to get
really good answers from the folks who monitor this group and figured
that someone could point me in the right direction.

Dennis

--
  _________
 |~~      @|
 |  ====   | Dennis Roman Gesker        ICQ: 194047
 |  ====   | mailto:dennis@gesker.com        Fax: 413.740.4653
 |_________| http://www.gesker.com



Re: Swing and JDBC

От
Sam Varshavchik
Дата:
Dennis R. Gesker writes:

> Now I'm considering reworking our database applications (currently in
> MS-Access) using Java but I'm looking for a small application that uses
> Swing & JDBC that can give me an idea of the best practices using these 2
> different parts of the API together. I of course intend to use Postgres
> for the back end but I think that the Java would be the way to go for the
> front end.

There's nothing particular about the combination of Swing and JDBC that
introduces a unique set of "best practices" that do not already apply to
either Swing, or JDBC; separately or in any combination with other APIs.

I do happen to have a fairly large (but feature-incomplete) Swing
application that uses postgresql-jdbc; but it's doubtful that anyone would
be able to identify some particular "best practice", of any kind, looking at
the source.  In fact, the Swing and JDBC components are completely and
totally separate -- one of the options is to run the Swing UI component as a
browser applet, which makes RMI calls to the server where the JDBC component
handles the RMI calls.  This would probably be the only kind of a "best
practice", if there is one at all -- to keep the two components completely
separated from each other, and use an intermediate API to communicate back
and forth.



--
Sam


Re: Swing and JDBC

От
"David Wall"
Дата:
> In fact, the Swing and JDBC components are completely and
> totally separate -- one of the options is to run the Swing UI component as
a
> browser applet, which makes RMI calls to the server where the JDBC
component
> handles the RMI calls.  This would probably be the only kind of a "best
> practice", if there is one at all -- to keep the two components completely
> separated from each other, and use an intermediate API to communicate back
> and forth.

In general, I agree.  It's typically not great to have a client component
access the database directly.  First, it means that the client must have the
database userid and password, and the database must be accessible to the
client (which is probably okay over a trusted LAN, but definitely more of an
issue over the Internet).  By using a server-side component (ala servlets or
EJB or even an RMI server), the requests from the client are handled by the
server, and the server can then use a database connection pool for all of
the client requests.  Therefore, if you have 20 clients, instead of needing
20 connections to the database, you may only have a few since the server can
use a pool since it's unlikely that all 20 client connections would be
active all the time.

David


Re: Swing and JDBC

От
Dave Cramer
Дата:
Dennis,

Have a look at persistence layers, www.ambysoft.com
or www.castor.org

In general you don't want your client accessing the db directly.

Dave
On Mon, 2002-08-12 at 18:17, Dennis R. Gesker wrote:
> Could someone on this list point me toward a simple but illustrative
> application built in Swing that uses JDBC (perferrably Postgres JDBC).
>
> I've been using the JDBC driver on Apache/Tomcat/Linux to generate web
> reports reading records from postgres and it has been working great.
>
> Now I'm considering reworking our database applications (currently in
> MS-Access) using Java but I'm looking for a small application that uses
> Swing & JDBC that can give me an idea of the best practices using these
> 2 different parts of the API together. I of course intend to use
> Postgres for the back end but I think that the Java would be the way to
> go for the front end.
>
> I've found alot of examples for either Swing or JDBC sepearately but
> none showing them together and working efficiently. I expect my
> application will have to support about 20 concurrent users but the
> structure of the database tables will only require a few tables and some
> relatively simple relationships.
>
> Sorry in advance if this is too far off topic but I always seem to get
> really good answers from the folks who monitor this group and figured
> that someone could point me in the right direction.
>
> Dennis
>
> --
>   _________
>  |~~      @|
>  |  ====   | Dennis Roman Gesker        ICQ: 194047
>  |  ====   | mailto:dennis@gesker.com        Fax: 413.740.4653
>  |_________| http://www.gesker.com
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>
>




Re: Swing and JDBC

От
"Dennis R. Gesker"
Дата:
Robert,

I am moving slowly but sure I'm more than willing to share anything  I
come accross. There does seem to be a consensus in the list regarding
using a middle teir as opposed to mixing the JDBC and Swing code
directly at the client. I was planning on continuing to use JSP pages to
provide all or the reporting so perhaps I can just point my existing
pages at this same middle tier.

There seems to be a number of choices for this middle teir. This teir
might also have mechanisms for addressing some of the issues you raise.
I'll probably begin researching some of these same issues this week.  I
wonder if my question now become what is the best way to construct this
middle teir.

Let me know I'll send you my config files.If you decide to use JSP pages
for reporting also I can probably also help you getting Tomcat to play
nice with Apache. Also, much of the information that will be kept in
postgres is data that I pull from our Accounting system (MS-SQL based
application) so I also have some classes built for pulling records and
getting them ready for postgres.

--Dennis

Booth, Robert wrote:

>Dennis,
>
>    I'm currently in the same position that you are.  I'm planning, if
>the company lets me, to rewrite an Access application in Java with Postgres
>as the backend.  I recently ported the data from Access to Postgres but left
>the client as Access due to time constraints.  Now I'm looking into
>re-designing the whole thing from the ground up and Java/Swing is my current
>choice of client, and of course Postgres as the DB.
>
>    Anyway I've been looking for the same thing you are.  My main
>stumbling block is that I've not found any information on the correct way to
>handle concurrent usage.  What is the proper/best way to handle 2 users
>editing the same record at the same time?  Should locks be implemented
>forcing 1 user to wait until the other is done editing, or should a write
>conflict message be displayed when the second edit is processed and the
>original record is found to have changed?  Also how should one go about
>checking for a record change given if you aren't using locks?  And how
>should the system be designed, is using "data objects" (objects that only
>deal with 1 type of record set) a good or bad idea?  What should be the
>proper way to populate and show your data to the user? Should the user be
>required to ask for there data to be refreshed, or should this be automatic?
>
>    These are the types of questions that have been running around in my
>mind with no answers forthcoming.  So I'm thinking that maybe we could help
>each other out since we are heading down the same path.  The only things
>I've found so far are database browsers like SquirrelSQL
>(http://squirrel-sql.sourceforge.net/), and I don't think these address the
>issues that I'm concerned with, and you are probably in the same boat.
>
>Rob
>
>
>
>>-----Original Message-----
>>From: Dennis R. Gesker [mailto:dennis@gesker.com]
>>Sent: Monday, August 12, 2002 3:17 PM
>>To: psql
>>Subject: [JDBC] Swing and JDBC
>>
>>
>>Could someone on this list point me toward a simple but illustrative
>>application built in Swing that uses JDBC (perferrably Postgres JDBC).
>>
>>I've been using the JDBC driver on Apache/Tomcat/Linux to
>>generate web
>>reports reading records from postgres and it has been working great.
>>
>>Now I'm considering reworking our database applications (currently in
>>MS-Access) using Java but I'm looking for a small application
>>that uses
>>Swing & JDBC that can give me an idea of the best practices
>>using these
>>2 different parts of the API together. I of course intend to use
>>Postgres for the back end but I think that the Java would be
>>the way to
>>go for the front end.
>>
>>I've found alot of examples for either Swing or JDBC sepearately but
>>none showing them together and working efficiently. I expect my
>>application will have to support about 20 concurrent users but the
>>structure of the database tables will only require a few
>>tables and some
>>relatively simple relationships.
>>
>>Sorry in advance if this is too far off topic but I always
>>seem to get
>>really good answers from the folks who monitor this group and figured
>>that someone could point me in the right direction.
>>
>>Dennis
>>
>>--
>>  _________
>> |~~      @|
>> |  ====   | Dennis Roman Gesker        ICQ: 194047
>> |  ====   | mailto:dennis@gesker.com        Fax: 413.740.4653
>> |_________| http://www.gesker.com
>>
>>
>>
>>---------------------------(end of
>>broadcast)---------------------------
>>TIP 4: Don't 'kill -9' the postmaster
>>
>>
>>

--
  _________
 |~~      @|
 |  ====   | Dennis Roman Gesker        ICQ: 194047
 |  ====   | mailto:dennis@gesker.com        Fax: 413.740.4653
 |_________| http://www.gesker.com



Re: Swing and JDBC

От
Dave Cramer
Дата:
Dennis, Robert,

have a look at www.ambysoft.com for a paper on persistence layers, with
a persistence layer your objects don't know anything about the db(s)


Dave
On Tue, 2002-08-13 at 10:51, Dennis R. Gesker wrote:
> Robert,
>
> I am moving slowly but sure I'm more than willing to share anything  I
> come accross. There does seem to be a consensus in the list regarding
> using a middle teir as opposed to mixing the JDBC and Swing code
> directly at the client. I was planning on continuing to use JSP pages to
> provide all or the reporting so perhaps I can just point my existing
> pages at this same middle tier.
>
> There seems to be a number of choices for this middle teir. This teir
> might also have mechanisms for addressing some of the issues you raise.
> I'll probably begin researching some of these same issues this week.  I
> wonder if my question now become what is the best way to construct this
> middle teir.
>
> Let me know I'll send you my config files.If you decide to use JSP pages
> for reporting also I can probably also help you getting Tomcat to play
> nice with Apache. Also, much of the information that will be kept in
> postgres is data that I pull from our Accounting system (MS-SQL based
> application) so I also have some classes built for pulling records and
> getting them ready for postgres.
>
> --Dennis
>
> Booth, Robert wrote:
>
> >Dennis,
> >
> >    I'm currently in the same position that you are.  I'm planning, if
> >the company lets me, to rewrite an Access application in Java with Postgres
> >as the backend.  I recently ported the data from Access to Postgres but left
> >the client as Access due to time constraints.  Now I'm looking into
> >re-designing the whole thing from the ground up and Java/Swing is my current
> >choice of client, and of course Postgres as the DB.
> >
> >    Anyway I've been looking for the same thing you are.  My main
> >stumbling block is that I've not found any information on the correct way to
> >handle concurrent usage.  What is the proper/best way to handle 2 users
> >editing the same record at the same time?  Should locks be implemented
> >forcing 1 user to wait until the other is done editing, or should a write
> >conflict message be displayed when the second edit is processed and the
> >original record is found to have changed?  Also how should one go about
> >checking for a record change given if you aren't using locks?  And how
> >should the system be designed, is using "data objects" (objects that only
> >deal with 1 type of record set) a good or bad idea?  What should be the
> >proper way to populate and show your data to the user? Should the user be
> >required to ask for there data to be refreshed, or should this be automatic?
> >
> >    These are the types of questions that have been running around in my
> >mind with no answers forthcoming.  So I'm thinking that maybe we could help
> >each other out since we are heading down the same path.  The only things
> >I've found so far are database browsers like SquirrelSQL
> >(http://squirrel-sql.sourceforge.net/), and I don't think these address the
> >issues that I'm concerned with, and you are probably in the same boat.
> >
> >Rob
> >
> >
> >
> >>-----Original Message-----
> >>From: Dennis R. Gesker [mailto:dennis@gesker.com]
> >>Sent: Monday, August 12, 2002 3:17 PM
> >>To: psql
> >>Subject: [JDBC] Swing and JDBC
> >>
> >>
> >>Could someone on this list point me toward a simple but illustrative
> >>application built in Swing that uses JDBC (perferrably Postgres JDBC).
> >>
> >>I've been using the JDBC driver on Apache/Tomcat/Linux to
> >>generate web
> >>reports reading records from postgres and it has been working great.
> >>
> >>Now I'm considering reworking our database applications (currently in
> >>MS-Access) using Java but I'm looking for a small application
> >>that uses
> >>Swing & JDBC that can give me an idea of the best practices
> >>using these
> >>2 different parts of the API together. I of course intend to use
> >>Postgres for the back end but I think that the Java would be
> >>the way to
> >>go for the front end.
> >>
> >>I've found alot of examples for either Swing or JDBC sepearately but
> >>none showing them together and working efficiently. I expect my
> >>application will have to support about 20 concurrent users but the
> >>structure of the database tables will only require a few
> >>tables and some
> >>relatively simple relationships.
> >>
> >>Sorry in advance if this is too far off topic but I always
> >>seem to get
> >>really good answers from the folks who monitor this group and figured
> >>that someone could point me in the right direction.
> >>
> >>Dennis
> >>
> >>--
> >>  _________
> >> |~~      @|
> >> |  ====   | Dennis Roman Gesker        ICQ: 194047
> >> |  ====   | mailto:dennis@gesker.com        Fax: 413.740.4653
> >> |_________| http://www.gesker.com
> >>
> >>
> >>
> >>---------------------------(end of
> >>broadcast)---------------------------
> >>TIP 4: Don't 'kill -9' the postmaster
> >>
> >>
> >>
>
> --
>   _________
>  |~~      @|
>  |  ====   | Dennis Roman Gesker        ICQ: 194047
>  |  ====   | mailto:dennis@gesker.com        Fax: 413.740.4653
>  |_________| http://www.gesker.com
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>
>