tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Roy Leonardus <hyde.par...@gmail.com>
Subject Re: BasicDataSource creation throws SQLException
Date Wed, 10 Aug 2016 15:11:52 GMT
Hello Christopher,

Thank you for the tip, i managed to test the code using the apache Derby
now.

it would be interesting to enhance the driver class to respond with some
result set, but i need to review it again.

and it will be another homework for me.

Roy

On Tue, Aug 9, 2016 at 8:54 PM, Christopher Schultz <
chris@christopherschultz.net> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> Roy,
>
> On 8/3/16 10:03 AM, Roy Leonardus wrote:
> > i'm using the EasyMock to test the creation of the BasicDataSource
> > :
> >
> > BasicDataSource ds = prepareDataSource(); //set the properties of
> > the basic data source Connection connection = ds.getConnection();
> > // throw an error here
>
> Full stack trace please?
>
> > The properties that is set is
> >
> > bds.setMaxTotal(maxTotal); bds.setMinIdle(minIdle);
> > bds.setMaxIdle(maxIdle);
> > bds.setNumTestsPerEvictionRun(numTestsPerEvictionRun);
> > bds.setMaxWaitMillis(maxWaitMillis);
> > bds.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
> > bds.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
> >
> >
> bds.setTestOnBorrow(true);
>
> Okay... most of those values aren't certain. Care to elaborate?
>
> > i do set the bds.setValidationQuery("Select 1") after checking the
> > source code and manage to proceed to have another error :
> >
> > *java.lang.NullPointerException: while trying to invoke the method
> > java.sql.PreparedStatement.executeQuery() of a null object loaded
> > from field
> > org.apache.tomcat.dbcp.dbcp2.PoolableConnection.validationPreparedStat
> ement
> >
> >
> of an object loaded from local variable*
> >
> >> From what i see, the BDS expect a return row result from the
> >> driver, and as
> > i am using a "fake" driver, there is no return row, i'm just not
> > sure based on my trial.
> >
> > sorry if my question is a little bit weird, it is a first time for
> > me.
>
> A fake driver should be okay to use, but you do have to make sure it
> follows the rules... for example, ResultSets should return rows (or
> return false from a call to next) or throw an SQLException.
>
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Comment: GPGTools - http://gpgtools.org
> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
>
> iQIcBAEBCAAGBQJXqibPAAoJEBzwKT+lPKRY8awP/3RFGqZnUgXwbSZmB6149gA5
> bPrJVqk3A1Y6V73DlaMA3jGWD09/G/QU6avNGcjfdHy01o37QmDAdTGwk1xOEIQn
> LBDy7GtzNVrj3x5wscg2FGq2M9oAh6FikNMS7ZyKHT6IrXOAjvGzM4C5V0pawBU/
> 0iJjKnEG6rW7e5PDZFFmteW4OVWnXQ25hrsUHzDJbLJ3e4cJSZGJvZFn0N5sGbiS
> 5tXhWPhegD8haVtvQcCamyzgII5UJtXMOQeR0Xzfr+U7YWj3o5cX2BDCVrclIAEi
> h9Zfrb6rqD45uvrkbHUbm1sm9R6aIILgk7TwPd7Hk3fldl2HyswMWAkdBnfs5pLr
> bZLEgpKi15e+RH71IILzmjMbbmkRyDSEtXWLUMOKFWMRK3sE0taTdRMuk7ktfwVU
> moUE945AUwBMWvZopsTSfnzpCReXG3uC4mSuIlLSLNyhtsbWrcC3rsNd5/h91h8p
> izS+MO2b0p+0auMMAscS/9Ch/fxxQAkBq/kk2S5eo/QpPxCZwhQTWJ7c6725YK1o
> lTWeGihiP1rb1cFYRE/A1vdKE5ZlO6MWc1FtH+nCwTZ3McJr9jNg/9plP60hHb/i
> aPrlND1BgW59C3OFnqxTVBaqQSlRVGxbjwVhDIggIAmjzemg1sxv3XJA+Je8mNKh
> NilChyWDRj5B6qXklWH9
> =mKAX
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message