Re: Problem with in-memory connector MXJ
Pierre Goupil <[email protected]> Thu, 29 Dec 2011 17:05:48 +0100
| Newsgroups | gmane.comp.db.mysql.java |
|---|---|
| Message-ID | <CAJJSjz79C21mjVBkgnyR4-cR4dE_EJTYLi2RNUUJ5a+1c5eF6g@mail.gmail.com> |
--f46d0444e86f730c1004b53d4b7b Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Mmmmmh. It looks like it works! Thanx! Pierre 2011/12/21 Celil Germeyan <[email protected]> > Try something like this... please change some variables based on your > environment: > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D**=3D > Connection con =3D null ; > Class.forName( "org.gjt.mm.mysql.Driver" ).newInstance( ) ; > > Properties prop =3D new Properties( ) ; > prop.put( "user", "myusername" ) ; > prop.put( "password", "mypassword" ) ; > prop.put( "characterEncoding", "utf8" ) ; > prop.put( "useUnicode", "true" ) ; > prop.put( "zeroDateTimeBehavior", "convertToNull" ) ; > prop.put( "useServerPrepStmts", "false" ) ; > prop.put( "cachePreparedStatements", "true" ) ; > > String url =3D "jdbc:mysql://localhost/**mysqldbname"; > > con =3D DriverManager.getConnection( url, prop ) ; > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > Celil > > > On 12/21/2011 02:24 PM, Pierre Goupil wrote: > >> Good afternoon, >> >> I'm currently trying and configure MySQL in order to have an in-memory >> database in my unit tests. My environment is: Linux 3.0.0, Java 6 openJD= K, >> MySQL connector 5.0.7 and MXJ 5.0.12. >> >> Here's my code: >> >> ------------------ >> String driver =3D System.getProperty("SQL_**DRIVER", >> "com.mysql.jdbc.Driver"); >> String defaultUrl =3D >> "jdbc:mysql:///test?**propertiesTransform=3Dcom.mysql.**management.jmx.*= * >> ConnectorMXJPropertiesTransfor**m"; >> >> String url =3D System.getProperty("SQL_URL", defaultUrl); >> String user =3D System.getProperty("SQL_USER", "root"); >> String password =3D System.getProperty("SQL_PW", ""); >> >> Class.forName(driver); >> >> Connection conn =3D DriverManager.getConnection(**url, user, password); >> ------------------ >> >> I get an exception at the last line: >> >> ------------------ >> Exception in thread "main" java.lang.**IndexOutOfBoundsException: Index: >> 0, >> Size: 0 >> at java.util.ArrayList.**rangeCheck(ArrayList.java:571) >> at java.util.ArrayList.get(**ArrayList.java:349) >> at >> com.mysql.management.jmx.**ConnectorMXJPropertiesTransfor**m.<init>(** >> ConnectorMXJPropertiesTransfor**m.java:63) >> >> at sun.reflect.**NativeConstructorAccessorImpl.**newInstance0(Native >> Method) >> at >> sun.reflect.**NativeConstructorAccessorImpl.**newInstance(** >> NativeConstructorAccessorImpl.**java:57) >> >> at >> sun.reflect.**DelegatingConstructorAccessorI**mpl.newInstance(** >> DelegatingConstructorAccessorI**mpl.java:45) >> >> at java.lang.reflect.Constructor.**newInstance(Constructor.java:**532) >> at java.lang.Class.newInstance0(**Class.java:372) >> at java.lang.Class.newInstance(**Class.java:325) >> at >> com.mysql.jdbc.**NonRegisteringDriver.parseURL(** >> NonRegisteringDriver.java:639) >> at >> com.mysql.jdbc.**NonRegisteringDriver.connect(** >> NonRegisteringDriver.java:280) >> at java.sql.DriverManager.**getConnection(DriverManager.**java:620) >> at java.sql.DriverManager.**getConnection(DriverManager.**java:200) >> at mxj.Start.main(Start.java:25) >> ------------------ >> >> A clue, anyone? Any help will be much appreciated. >> >> Regards, >> >> Pierre Goupil >> >> >> >> >> --=20 Si tu penses que la violence ne r=C3=A9sout rien, c'est que tu n'as pas tap= =C3=A9 assez fort. --f46d0444e86f730c1004b53d4b7b--