You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Ashish Kulkarni <as...@gmail.com> on 2007/11/21 22:15:37 UTC

Setting up user id, password for JDBC connection

Hi
I am working on a swing application where the user enters his user id and
password, then this user id and password is required to create SqlMapClient,
this is what i am tried but did not work
in my sqlconfig.xml file i have
<dataSource type="SIMPLE">
<property name="JDBC.Driver" value="${driver}" />
<property name="JDBC.ConnectionURL" value="${url}" />
<property name="JDBC.Username" value="${username}" />
<property name="JDBC.Password" value="${password}" />
</dataSource>

And in my java program
I do
System.setProperty("driver", JDBCdrivername);
System.setProperty("url", url);
System.setProperty("username", username);
System.setProperty("password", password);

String resource = "com/pfizer/maps/sqlmap/sql/SQLMapConfigAS400.xml";
Reader reader = Resources.getResourceAsReader(resource);
SqlMapClient sqlMapClient = SqlMapClientBuilder.buildSqlMapClient(reader);

Any ideas of how do i get it working in Swing application

Ashish

Re: Setting up user id, password for JDBC connection

Posted by Larry Meadors <lm...@apache.org>.
You have the property names wrong.

${driver} means the property should be "driver", not "JDBC.Driver".

Larry


On Nov 26, 2007 12:35 PM, Ashish Kulkarni <as...@gmail.com> wrote:
> Hi
> I tried the following but getting error, any ideas
>
> Properties prop = new Properties();
>  prop.put("JDBC.Driver", "com.ibm.as400.access.AS400JDBCDriver");
>  prop.put("JDBC.Username ", user);
>  prop.put("JDBC.Password", password);
>  prop.put("JDBC.ConnectionURL",
> "jdbc:as400:"+as400Name+"/"+library+";naming=system;date format=iso;time
> format=hms;prompt=false");
>
>
> String resource = "com/pfizer/maps/sqlmap/sql/SQLMapConfigAS400.xml";
>  Reader reader = Resources.getResourceAsReader(resource);
>  sqlMapClient = SqlMapClientBuilder.buildSqlMapClient(reader, prop);
>
> and in my SQLMapConfigAS400.xml i have
> <transactionManager type="JDBC">
>
>
>  <dataSource type="SIMPLE">
>  <property name="JDBC.Driver" value="${driver}" />
>
>  <property name="JDBC.ConnectionURL" value="${url}" />
>
>  <property name="JDBC.Username" value="${username}" />
>
>  <property name=" JDBC.Password" value="${password}" />
>
>  </dataSource>
>  </transactionManager>
>
> It gives me error, does anyone one have any example for get it working
>
> Ashish
>
>
>
>
>
>
>
> On 11/21/07, Christopher Lamey <cl...@localmatters.com> wrote:
> > Try creating a properties object, setting the name/value pairs on that,
> and
> > passing that into:
> >
> >     public static SqlMapClient buildSqlMapClient(java.io.Reader reader,
> > java.util.Properties props)
> >
> > Cheers,
> > Chris
> >
> > On 11/21/07 2:15 PM, "Ashish Kulkarni" <as...@gmail.com>
> wrote:
> >
> > > Hi
> > > I am working on a swing application where the user enters his user id
> and
> > > password, then this user id and password is required to create
> SqlMapClient,
> > > this is what i am tried but did not work
> > > in my sqlconfig.xml file i have
> > > <dataSource type="SIMPLE">
> > > <property name="JDBC.Driver" value="${driver}" />
> > > <property name="JDBC.ConnectionURL" value="${url}" />
> > > <property name="JDBC.Username" value="${username}" />
> > > <property name="JDBC.Password" value="${password}" />
> > > </dataSource>
> > >
> > > And in my java program
> > > I do
> > > System.setProperty("driver", JDBCdrivername);
> > > System.setProperty("url", url);
> > > System.setProperty("username", username);
> > > System.setProperty("password", password);
> > >
> > > String resource = "com/pfizer/maps/sqlmap/sql/SQLMapConfigAS400.xml";
> > > Reader reader = Resources.getResourceAsReader(resource);
> > > SqlMapClient sqlMapClient =
> SqlMapClientBuilder.buildSqlMapClient(reader);
> > >
> > > Any ideas of how do i get it working in Swing application
> > >
> > > Ashish
> >
> >
>
>

Re: Setting up user id, password for JDBC connection

Posted by Ashish Kulkarni <as...@gmail.com>.
Hi
I tried the following but getting error, any ideas

Properties prop = new Properties();
prop.put("JDBC.Driver", "com.ibm.as400.access.AS400JDBCDriver");
prop.put("JDBC.Username", user);
prop.put("JDBC.Password", password);
prop.put("JDBC.ConnectionURL",
"jdbc:as400:"+as400Name+"/"+library+";naming=system;date format=iso;time
format=hms;prompt=false");

String resource = "com/pfizer/maps/sqlmap/sql/SQLMapConfigAS400.xml";
Reader reader = Resources.getResourceAsReader(resource);
sqlMapClient = SqlMapClientBuilder.buildSqlMapClient(reader, prop);

and in my SQLMapConfigAS400.xml i have
<transactionManager type="JDBC">

<dataSource type="SIMPLE">
<property name="JDBC.Driver" value="${driver}" />

<property name="JDBC.ConnectionURL" value="${url}" />

<property name="JDBC.Username" value="${username}" />

<property name="JDBC.Password" value="${password}" />

</dataSource>
</transactionManager>

It gives me error, does anyone one have any example for get it working

Ashish





On 11/21/07, Christopher Lamey <cl...@localmatters.com> wrote:
>
> Try creating a properties object, setting the name/value pairs on that,
> and
> passing that into:
>
>     public static SqlMapClient buildSqlMapClient(java.io.Reader reader,
> java.util.Properties props)
>
> Cheers,
> Chris
>
> On 11/21/07 2:15 PM, "Ashish Kulkarni" <as...@gmail.com>
> wrote:
>
> > Hi
> > I am working on a swing application where the user enters his user id
> and
> > password, then this user id and password is required to create
> SqlMapClient,
> > this is what i am tried but did not work
> > in my sqlconfig.xml file i have
> > <dataSource type="SIMPLE">
> > <property name="JDBC.Driver" value="${driver}" />
> > <property name="JDBC.ConnectionURL" value="${url}" />
> > <property name="JDBC.Username" value="${username}" />
> > <property name="JDBC.Password" value="${password}" />
> > </dataSource>
> >
> > And in my java program
> > I do
> > System.setProperty("driver", JDBCdrivername);
> > System.setProperty("url", url);
> > System.setProperty("username", username);
> > System.setProperty("password", password);
> >
> > String resource = "com/pfizer/maps/sqlmap/sql/SQLMapConfigAS400.xml";
> > Reader reader = Resources.getResourceAsReader(resource);
> > SqlMapClient sqlMapClient = SqlMapClientBuilder.buildSqlMapClient
> (reader);
> >
> > Any ideas of how do i get it working in Swing application
> >
> > Ashish
>
>

Re: Setting up user id, password for JDBC connection

Posted by Christopher Lamey <cl...@localmatters.com>.
Try creating a properties object, setting the name/value pairs on that, and
passing that into:

    public static SqlMapClient buildSqlMapClient(java.io.Reader reader,
java.util.Properties props)

Cheers,
Chris

On 11/21/07 2:15 PM, "Ashish Kulkarni" <as...@gmail.com> wrote:

> Hi
> I am working on a swing application where the user enters his user id and
> password, then this user id and password is required to create SqlMapClient,
> this is what i am tried but did not work
> in my sqlconfig.xml file i have
> <dataSource type="SIMPLE">
> <property name="JDBC.Driver" value="${driver}" />
> <property name="JDBC.ConnectionURL" value="${url}" />
> <property name="JDBC.Username" value="${username}" />
> <property name="JDBC.Password" value="${password}" />
> </dataSource>
> 
> And in my java program
> I do
> System.setProperty("driver", JDBCdrivername);
> System.setProperty("url", url);
> System.setProperty("username", username);
> System.setProperty("password", password);
> 
> String resource = "com/pfizer/maps/sqlmap/sql/SQLMapConfigAS400.xml";
> Reader reader = Resources.getResourceAsReader(resource);
> SqlMapClient sqlMapClient = SqlMapClientBuilder.buildSqlMapClient(reader);
> 
> Any ideas of how do i get it working in Swing application
> 
> Ashish