You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@shiro.apache.org by Fabricio Pizzichillo <fp...@gmail.com> on 2011/08/16 15:40:43 UTC

JdbcRealm + Postgresql

hello friends.
can you help me set a jdbcrealm with postgresql?
Single encounter with Mysql documentation

Re: JdbcRealm + Postgresql

Posted by Fabricio Pizzichillo <fp...@gmail.com>.
Thanks!

2011/8/18 <sh...@xoxy.net>

> The property names are correct. The only problem is
> that org.Postgresql.Driver does not implement javax.sql.DataSource. Use the
> documentation to choose an appropriate class:
> http://jdbc.postgresql.org/documentation/publicapi/org/postgresql/ds/package-summary.html
>
>
> On Thu, Aug 18, 2011 at 1:22 PM, Phil Steitz - phil.steitz@gmail.com
>  wrote:
>
> On 8/16/11 2:43 PM, Fabricio Pizzichillo wrote:
>> > Hi Les,
>> > I follow some docs, and write this in shiro.ini
>> >
>> >
>> > *[main]*
>> > *jdbcRealm* = org.apache.*shiro*.realm.jdbc.*JdbcRealm*
>> > *jdbcRealm*.authenticationQuery = "SELECT password FROM users WHERE
>> > user_name = ?"
>> > ds = org.Postgresql.Driver
>> > ds.serverName = IP
>> > ds.user = user
>> > ds.password = pass
>> > ds.databaseName = DATABASE
>> > jdbcRealm.dataSource = $ds
>> >
>> > But ds.serverName does not exist.
>> > I have to change anything?
>>
>> Yes.  Those property names are for a MySQL JDBC datasource.
>> Consult the documentation for the postgres JDBC driver that you are
>> using. Use a DataSource for ds (i.e. a postgres DataSource
>> implementation or a connection pool).  Then look at the properties
>> exposed by the DataSource implementation and define these using the
>> ds.xxx properties above.
>>
>>
>> Phil
>> > Thanks
>> >
>> > 2011/8/16 Les Hazlewood <lh...@apache.org>
>> >
>> >> Hi Fabricio,
>> >>
>> >> Look at the JdbcRealm's implementation here:
>> >>
>> >>
>> >>
>> http://svn.apache.org/repos/asf/shiro/trunk/core/src/main/java/org/apache/shiro/realm/jdbc/JdbcRealm.java
>> >>
>> >> and notice the *_QUERY constants.  For testing, you can make your
>> >> tables structured so that the queries will work for you.  But mostly
>> >> they are there as a default and to give you ideas.
>> >>
>> >> Usually, you will create database tables as necessary and call the
>> >> set*Query(String query) methods to match your database schema.
>> >>
>> >> HTH,
>> >>
>> >> --
>> >> Les Hazlewood
>> >> CTO, Katasoft | http://www.katasoft.com | 888.391.5282
>> >> twitter: @lhazlewood | http://twitter.com/lhazlewood
>> >> katasoft blog: http://www.katasoft.com/blogs/lhazlewood
>> >> personal blog: http://leshazlewood.com
>> >>
>>
>>
>>
>

Re: JdbcRealm + Postgresql

Posted by Phil Steitz <ph...@gmail.com>.
On 8/18/11 10:45 AM, shiro.atomicknight@xoxy.net wrote:
> The property names are correct.
Yes, my mistake.  Looks like all below are standard property names
and should be provided by any DataSource.  Note that the getters /
setters are not, however, part of the DataSource interface and some
DataSources do not support some standard properties.  Technically,
only "description" is required by the spec.  For this reason, it is
always best to check the JDBC driver documentation to make sure the
properties you are using are supported with standard names and meaning.

Phil
>  The only problem is
> that org.Postgresql.Driver does not implement javax.sql.DataSource. Use the
> documentation to choose an appropriate class:
> http://jdbc.postgresql.org/documentation/publicapi/org/postgresql/ds/package-summary.html
>
>
> On Thu, Aug 18, 2011 at 1:22 PM, Phil Steitz - phil.steitz@gmail.com wrote:
>
>> On 8/16/11 2:43 PM, Fabricio Pizzichillo wrote:
>>> Hi Les,
>>> I follow some docs, and write this in shiro.ini
>>>
>>>
>>> *[main]*
>>> *jdbcRealm* = org.apache.*shiro*.realm.jdbc.*JdbcRealm*
>>> *jdbcRealm*.authenticationQuery = "SELECT password FROM users WHERE
>>> user_name = ?"
>>> ds = org.Postgresql.Driver
>>> ds.serverName = IP
>>> ds.user = user
>>> ds.password = pass
>>> ds.databaseName = DATABASE
>>> jdbcRealm.dataSource = $ds
>>>
>>> But ds.serverName does not exist.
>>> I have to change anything?
>> Yes.  Those property names are for a MySQL JDBC datasource.
>> Consult the documentation for the postgres JDBC driver that you are
>> using. Use a DataSource for ds (i.e. a postgres DataSource
>> implementation or a connection pool).  Then look at the properties
>> exposed by the DataSource implementation and define these using the
>> ds.xxx properties above.
>>
>>
>> Phil
>>> Thanks
>>>
>>> 2011/8/16 Les Hazlewood <lh...@apache.org>
>>>
>>>> Hi Fabricio,
>>>>
>>>> Look at the JdbcRealm's implementation here:
>>>>
>>>>
>>>>
>> http://svn.apache.org/repos/asf/shiro/trunk/core/src/main/java/org/apache/shiro/realm/jdbc/JdbcRealm.java
>>>> and notice the *_QUERY constants.  For testing, you can make your
>>>> tables structured so that the queries will work for you.  But mostly
>>>> they are there as a default and to give you ideas.
>>>>
>>>> Usually, you will create database tables as necessary and call the
>>>> set*Query(String query) methods to match your database schema.
>>>>
>>>> HTH,
>>>>
>>>> --
>>>> Les Hazlewood
>>>> CTO, Katasoft | http://www.katasoft.com | 888.391.5282
>>>> twitter: @lhazlewood | http://twitter.com/lhazlewood
>>>> katasoft blog: http://www.katasoft.com/blogs/lhazlewood
>>>> personal blog: http://leshazlewood.com
>>>>
>>
>>


Re: JdbcRealm + Postgresql

Posted by sh...@xoxy.net.
The property names are correct. The only problem is
that org.Postgresql.Driver does not implement javax.sql.DataSource. Use the
documentation to choose an appropriate class:
http://jdbc.postgresql.org/documentation/publicapi/org/postgresql/ds/package-summary.html


On Thu, Aug 18, 2011 at 1:22 PM, Phil Steitz - phil.steitz@gmail.com wrote:

> On 8/16/11 2:43 PM, Fabricio Pizzichillo wrote:
> > Hi Les,
> > I follow some docs, and write this in shiro.ini
> >
> >
> > *[main]*
> > *jdbcRealm* = org.apache.*shiro*.realm.jdbc.*JdbcRealm*
> > *jdbcRealm*.authenticationQuery = "SELECT password FROM users WHERE
> > user_name = ?"
> > ds = org.Postgresql.Driver
> > ds.serverName = IP
> > ds.user = user
> > ds.password = pass
> > ds.databaseName = DATABASE
> > jdbcRealm.dataSource = $ds
> >
> > But ds.serverName does not exist.
> > I have to change anything?
>
> Yes.  Those property names are for a MySQL JDBC datasource.
> Consult the documentation for the postgres JDBC driver that you are
> using. Use a DataSource for ds (i.e. a postgres DataSource
> implementation or a connection pool).  Then look at the properties
> exposed by the DataSource implementation and define these using the
> ds.xxx properties above.
>
>
> Phil
> > Thanks
> >
> > 2011/8/16 Les Hazlewood <lh...@apache.org>
> >
> >> Hi Fabricio,
> >>
> >> Look at the JdbcRealm's implementation here:
> >>
> >>
> >>
> http://svn.apache.org/repos/asf/shiro/trunk/core/src/main/java/org/apache/shiro/realm/jdbc/JdbcRealm.java
> >>
> >> and notice the *_QUERY constants.  For testing, you can make your
> >> tables structured so that the queries will work for you.  But mostly
> >> they are there as a default and to give you ideas.
> >>
> >> Usually, you will create database tables as necessary and call the
> >> set*Query(String query) methods to match your database schema.
> >>
> >> HTH,
> >>
> >> --
> >> Les Hazlewood
> >> CTO, Katasoft | http://www.katasoft.com | 888.391.5282
> >> twitter: @lhazlewood | http://twitter.com/lhazlewood
> >> katasoft blog: http://www.katasoft.com/blogs/lhazlewood
> >> personal blog: http://leshazlewood.com
> >>
>
>
>

Re: JdbcRealm + Postgresql

Posted by Phil Steitz <ph...@gmail.com>.
On 8/16/11 2:43 PM, Fabricio Pizzichillo wrote:
> Hi Les,
> I follow some docs, and write this in shiro.ini
>
>
> *[main]*
> *jdbcRealm* = org.apache.*shiro*.realm.jdbc.*JdbcRealm*
> *jdbcRealm*.authenticationQuery = "SELECT password FROM users WHERE
> user_name = ?"
> ds = org.Postgresql.Driver
> ds.serverName = IP
> ds.user = user
> ds.password = pass
> ds.databaseName = DATABASE
> jdbcRealm.dataSource = $ds
>
> But ds.serverName does not exist.
> I have to change anything?

Yes.  Those property names are for a MySQL JDBC datasource.  
Consult the documentation for the postgres JDBC driver that you are
using. Use a DataSource for ds (i.e. a postgres DataSource
implementation or a connection pool).  Then look at the properties
exposed by the DataSource implementation and define these using the
ds.xxx properties above.


Phil
> Thanks
>
> 2011/8/16 Les Hazlewood <lh...@apache.org>
>
>> Hi Fabricio,
>>
>> Look at the JdbcRealm's implementation here:
>>
>>
>> http://svn.apache.org/repos/asf/shiro/trunk/core/src/main/java/org/apache/shiro/realm/jdbc/JdbcRealm.java
>>
>> and notice the *_QUERY constants.  For testing, you can make your
>> tables structured so that the queries will work for you.  But mostly
>> they are there as a default and to give you ideas.
>>
>> Usually, you will create database tables as necessary and call the
>> set*Query(String query) methods to match your database schema.
>>
>> HTH,
>>
>> --
>> Les Hazlewood
>> CTO, Katasoft | http://www.katasoft.com | 888.391.5282
>> twitter: @lhazlewood | http://twitter.com/lhazlewood
>> katasoft blog: http://www.katasoft.com/blogs/lhazlewood
>> personal blog: http://leshazlewood.com
>>


Re: JdbcRealm + Postgresql

Posted by Fabricio Pizzichillo <fp...@gmail.com>.
Hi Les,
I follow some docs, and write this in shiro.ini


*[main]*
*jdbcRealm* = org.apache.*shiro*.realm.jdbc.*JdbcRealm*
*jdbcRealm*.authenticationQuery = "SELECT password FROM users WHERE
user_name = ?"
ds = org.Postgresql.Driver
ds.serverName = IP
ds.user = user
ds.password = pass
ds.databaseName = DATABASE
jdbcRealm.dataSource = $ds

But ds.serverName does not exist.
I have to change anything?
Thanks

2011/8/16 Les Hazlewood <lh...@apache.org>

> Hi Fabricio,
>
> Look at the JdbcRealm's implementation here:
>
>
> http://svn.apache.org/repos/asf/shiro/trunk/core/src/main/java/org/apache/shiro/realm/jdbc/JdbcRealm.java
>
> and notice the *_QUERY constants.  For testing, you can make your
> tables structured so that the queries will work for you.  But mostly
> they are there as a default and to give you ideas.
>
> Usually, you will create database tables as necessary and call the
> set*Query(String query) methods to match your database schema.
>
> HTH,
>
> --
> Les Hazlewood
> CTO, Katasoft | http://www.katasoft.com | 888.391.5282
> twitter: @lhazlewood | http://twitter.com/lhazlewood
> katasoft blog: http://www.katasoft.com/blogs/lhazlewood
> personal blog: http://leshazlewood.com
>

Re: JdbcRealm + Postgresql

Posted by Les Hazlewood <lh...@apache.org>.
Hi Fabricio,

Look at the JdbcRealm's implementation here:

http://svn.apache.org/repos/asf/shiro/trunk/core/src/main/java/org/apache/shiro/realm/jdbc/JdbcRealm.java

and notice the *_QUERY constants.  For testing, you can make your
tables structured so that the queries will work for you.  But mostly
they are there as a default and to give you ideas.

Usually, you will create database tables as necessary and call the
set*Query(String query) methods to match your database schema.

HTH,

-- 
Les Hazlewood
CTO, Katasoft | http://www.katasoft.com | 888.391.5282
twitter: @lhazlewood | http://twitter.com/lhazlewood
katasoft blog: http://www.katasoft.com/blogs/lhazlewood
personal blog: http://leshazlewood.com