Return-Path: Delivered-To: apmail-struts-user-archive@www.apache.org Received: (qmail 46752 invoked from network); 16 Jan 2007 12:15:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 16 Jan 2007 12:15:56 -0000 Received: (qmail 97686 invoked by uid 500); 16 Jan 2007 12:15:53 -0000 Delivered-To: apmail-struts-user-archive@struts.apache.org Received: (qmail 97147 invoked by uid 500); 16 Jan 2007 12:15:52 -0000 Mailing-List: contact user-help@struts.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Struts Users Mailing List" Reply-To: "Struts Users Mailing List" Delivered-To: mailing list user@struts.apache.org Received: (qmail 97136 invoked by uid 99); 16 Jan 2007 12:15:52 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Jan 2007 04:15:52 -0800 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of joegermuska@gmail.com designates 64.233.166.176 as permitted sender) Received: from [64.233.166.176] (HELO py-out-1112.google.com) (64.233.166.176) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Jan 2007 04:15:43 -0800 Received: by py-out-1112.google.com with SMTP id u52so1018564pyb for ; Tue, 16 Jan 2007 04:15:22 -0800 (PST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:sender:to:subject:in-reply-to:mime-version:content-type:references:x-google-sender-auth; b=fYHfV5OkdRRiPlAA3IBajr59ItSgW80bQpbSESUd75zJnkiAxblh1WH3esNvWCLBogJqvMmVSa0uM0Rf4R3ysnSu+XSI0rddTU9yyxA9Dlim3iFFfnNrmTPU9YzSU7IZZIHY5C96wzGgQkw4/HQTiX9QEDhJLpKARdkYnzkeIYk= Received: by 10.35.54.1 with SMTP id g1mr9990077pyk.1168949722056; Tue, 16 Jan 2007 04:15:22 -0800 (PST) Received: by 10.35.28.11 with HTTP; Tue, 16 Jan 2007 04:15:21 -0800 (PST) Message-ID: <242960fe0701160415uc2f9d44nac90102ab90bc659@mail.gmail.com> Date: Tue, 16 Jan 2007 06:15:21 -0600 From: "Joe Germuska" Sender: joegermuska@gmail.com To: "Struts Users Mailing List" Subject: Re: [Struts 2] Database access In-Reply-To: <200701161308.05393.plegal@appert44.org> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_28072_5389660.1168949721953" References: <45aca582.4b.da9.737794952@inet.hr> <200701161308.05393.plegal@appert44.org> X-Google-Sender-Auth: 00aae50be0056c59 X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_28072_5389660.1168949721953 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline This example is for Struts 1.x, not Struts 2. Struts 2 provides no direct support for managing database connections, although one could achieve something like this rather readily using Spring, or probably with any other ObjectFactory. Here's a tutorial which gets much more involved than your basic request, bu= t which might help. Note that since the tutorial uses Hibernate, it isn't exactly what you asked for, but it also demonstrates using Spring to instantiate a Datasource, and then you could have Spring also instantiate your Action Classes and "inject" the datasource dependency into them. http://cwiki.apache.org/S2WIKI/struts-2-spring-2-jpa-ajax.html Let me issue the standard disclaimer that if you are doing a lot of databas= e work in your Action classes, you may want to consider refactoring anyway. Joe On 1/16/07, Philippe Le Gal wrote: > > Hi, > > Thanks again. > Is it possible that you give me the complete listing of this example > because, > I've problem to find how to initialize the 'context' object. > > Thanks > > Philippe > > Le mardi 16 janvier 2007 11:14, Stanislav a =E9crit: > > in java action class you can also connect through struts db mechanisam: > > DataSource dataSource =3D (DataSource) > > context.getAttribute("org.apache.struts.action.DATA_SOURCE"); conn =3D > > dataSource.getConnection(); > > or direct to db > > Connection conn =3D > > DriverManager.getConnection > (ConnectionURL,ConnectionUserName,ConnectionPass > >word); > > > > > > > > From: Philippe Le Gal > > To: "Struts Users Mailing List" > > Subject: Re: [Struts 2] Database access > > Date: Tue, 16 Jan 2007 11:08:28 +0100 > > > > ----- Original Message Follows ----- > > > > > Hi, > > > > > > Thanks for the information. > > > I'm also looking for the mecanism of accessing the database in the > java > > > action class. > > > > > > Thanks > > > > > > Philippe > > > > > > Le mardi 16 janvier 2007 10:59, Stanislav a =E9crit : > > > > in struts-config for sql database. > > > > > > > > > > > > > > > > > > > value=3D"com.microsoft.jdbc.sqlserver.SQLServerDriver" /> > > > > > > > > value=3D"jdbc:microsoft:sqlserver://xxx.xxx.xxx.xxx:1433;DatabaseName=3Dx= xx > > > >xx;S electMethod=3DCursor" /> > > > value=3D"xxxxx" /> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > From: Philippe Le Gal > > > > To: user@struts.apache.org > > > > Subject: [Struts 2] Database access > > > > Date: Tue, 16 Jan 2007 10:53:12 +0100 > > > > > > > > ----- Original Message Follows ----- > > > > > > > > > Hi, > > > > > > > > > > I'm looking for a simple struts 2 database access example. > > > > > > > > > > Thanks for any url > > > > > > > > > > Philippe > > > > > > > > > > > --------------------------------------------------------------------- > > > > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org > > > > > For additional commands, e-mail: user-help@struts.apache.org > > > > > > > > > --------------------------------------------------------------------- > > > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org > > > > For additional commands, e-mail: user-help@struts.apache.org > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org > > > For additional commands, e-mail: user-help@struts.apache.org > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org > > For additional commands, e-mail: user-help@struts.apache.org > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org > For additional commands, e-mail: user-help@struts.apache.org > > --=20 Joe Germuska Joe@Germuska.com * http://blog.germuska.com "The truth is that we learned from Jo=E3o forever to be out of tune." -- Caetano Veloso ------=_Part_28072_5389660.1168949721953--