You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Tracy Zhu <tr...@gmail.com> on 2007/07/11 11:47:36 UTC

throws NullPointerException in using Java Request

hi all,

I hava written a Java Request to connect to Mysql Server(version 4.1) and do
some operations. I have put the .jar file and its referenced
mysql-connector-java-5.0.4-bin.jar under lib/ext. but the Java Request
doesn't work. following is information from jmeter.log:
ERROR - jmeter.threads.JMeterThread:  java.lang.NullPointerException
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)    // this one in the code is
Class.forName("com.mysql.jdbc.Driver");
    at DBCommon.getCrdbConnection(DBCommon.java:34)
    at DeletePreCRDCUsers.runTest(DeletePreCRDCUsers.java:29)
    at org.apache.jmeter.protocol.java.sampler.JavaSampler.sample(
JavaSampler.java:163)
    at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:247)
    at java.lang.Thread.run(Unknown Source)

>
> what's wrong with my Java Request?

Re: throws NullPointerException in using Java Request

Posted by sebb <se...@gmail.com>.
The JDBC Sampler saves the reply in the responseData field of the
sample response, but just converts it to a string. You could perhaps
process that with a BeanShell post-processor if your data is regular
enough.

Otherwise, I would suggest creating your own version of the JDBC
sampler and modifying that to do what you want, rather than starting
afresh with the JavaSampler.

All the files are in the package

org.apache.jmeter.protocol.jdbc.sampler

Make sure you use the current code in branches/rel-2-2 (or a recent
nightly) as there have been some fixes since 2.2.

S.
On 11/07/07, Tracy Zhu <tr...@gmail.com> wrote:
> I have to save the query result from Mysql into a csv file. besides, i need
> to insert more columns into the same csv file. So I planned to add the query
> results and other data row by row. Is there other ways I can implement such
> function?
> Thanks.
>
> On 7/11/07, sebb <se...@gmail.com> wrote:
> >
> > On 11/07/07, Tracy Zhu <tr...@gmail.com> wrote:
> > > hi all,
> > >
> > > I hava written a Java Request to connect to Mysql Server(version 4.1)
> > and do
> > > some operations. I have put the .jar file and its referenced
> > > mysql-connector-java-5.0.4-bin.jar under lib/ext. but the Java Request
> > > doesn't work. following is information from jmeter.log:
> > > ERROR - jmeter.threads.JMeterThread:  java.lang.NullPointerException
> > >    at java.lang.Class.forName0(Native Method)
> > >    at java.lang.Class.forName(Unknown Source)    // this one in the code
> > is
> > > Class.forName("com.mysql.jdbc.Driver");
> > >    at DBCommon.getCrdbConnection(DBCommon.java:34)
> > >    at DeletePreCRDCUsers.runTest(DeletePreCRDCUsers.java:29)
> > >    at org.apache.jmeter.protocol.java.sampler.JavaSampler.sample(
> > > JavaSampler.java:163)
> > >    at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:247)
> > >    at java.lang.Thread.run(Unknown Source)
> > >
> > > >
> > > > what's wrong with my Java Request?
> >
> > JMeter already has a JDBC sampler, so why not use that?
> >
> > S.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
> >
> >
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: throws NullPointerException in using Java Request

Posted by Tracy Zhu <tr...@gmail.com>.
I have to save the query result from Mysql into a csv file. besides, i need
to insert more columns into the same csv file. So I planned to add the query
results and other data row by row. Is there other ways I can implement such
function?
Thanks.

On 7/11/07, sebb <se...@gmail.com> wrote:
>
> On 11/07/07, Tracy Zhu <tr...@gmail.com> wrote:
> > hi all,
> >
> > I hava written a Java Request to connect to Mysql Server(version 4.1)
> and do
> > some operations. I have put the .jar file and its referenced
> > mysql-connector-java-5.0.4-bin.jar under lib/ext. but the Java Request
> > doesn't work. following is information from jmeter.log:
> > ERROR - jmeter.threads.JMeterThread:  java.lang.NullPointerException
> >    at java.lang.Class.forName0(Native Method)
> >    at java.lang.Class.forName(Unknown Source)    // this one in the code
> is
> > Class.forName("com.mysql.jdbc.Driver");
> >    at DBCommon.getCrdbConnection(DBCommon.java:34)
> >    at DeletePreCRDCUsers.runTest(DeletePreCRDCUsers.java:29)
> >    at org.apache.jmeter.protocol.java.sampler.JavaSampler.sample(
> > JavaSampler.java:163)
> >    at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:247)
> >    at java.lang.Thread.run(Unknown Source)
> >
> > >
> > > what's wrong with my Java Request?
>
> JMeter already has a JDBC sampler, so why not use that?
>
> S.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>

Re: throws NullPointerException in using Java Request

Posted by sebb <se...@gmail.com>.
On 11/07/07, Tracy Zhu <tr...@gmail.com> wrote:
> hi all,
>
> I hava written a Java Request to connect to Mysql Server(version 4.1) and do
> some operations. I have put the .jar file and its referenced
> mysql-connector-java-5.0.4-bin.jar under lib/ext. but the Java Request
> doesn't work. following is information from jmeter.log:
> ERROR - jmeter.threads.JMeterThread:  java.lang.NullPointerException
>    at java.lang.Class.forName0(Native Method)
>    at java.lang.Class.forName(Unknown Source)    // this one in the code is
> Class.forName("com.mysql.jdbc.Driver");
>    at DBCommon.getCrdbConnection(DBCommon.java:34)
>    at DeletePreCRDCUsers.runTest(DeletePreCRDCUsers.java:29)
>    at org.apache.jmeter.protocol.java.sampler.JavaSampler.sample(
> JavaSampler.java:163)
>    at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:247)
>    at java.lang.Thread.run(Unknown Source)
>
> >
> > what's wrong with my Java Request?

JMeter already has a JDBC sampler, so why not use that?

S.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: throws NullPointerException in using Java Request

Posted by Hugh Hunter <hh...@oversee.net>.
On Wed, 2007-07-11 at 17:47 +0800, Tracy Zhu wrote:
> hi all,
> 
> I hava written a Java Request to connect to Mysql Server(version 4.1) and do
> some operations. I have put the .jar file and its referenced
> mysql-connector-java-5.0.4-bin.jar under lib/ext. but the Java Request
> doesn't work. following is information from jmeter.log:
> ERROR - jmeter.threads.JMeterThread:  java.lang.NullPointerException
>     at java.lang.Class.forName0(Native Method)
>     at java.lang.Class.forName(Unknown Source)    // this one in the code is
> Class.forName("com.mysql.jdbc.Driver");
>     at DBCommon.getCrdbConnection(DBCommon.java:34)
>     at DeletePreCRDCUsers.runTest(DeletePreCRDCUsers.java:29)
>     at org.apache.jmeter.protocol.java.sampler.JavaSampler.sample(
> JavaSampler.java:163)
>     at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:247)
>     at java.lang.Thread.run(Unknown Source)
> 
> >
> > what's wrong with my Java Request?

Tracy,

For what it's worth, I have been unsuccessful in getting Jmeter to work
with that version of the connector jar.  Try
mysql-connector-java-3.1.14-bin.jar.

--Hugh


---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org