Currently tables created in MySQL default to MyISam. This is unacceptable for us at Openmrs. You can set a property in your my.cnf file called “default-storage-engine”, but I needed a solution that didn’t involve implementers having to modify their system config files.

I changed the jdbc connection url string to set a session property that sets InnoDB as the default engine:

jdbc:mysql://localhost:3306/databasename?autoReconnect=true&sessionVariables=storage_engine=InnoDB

NOTE! Requires mysql jdbc connecter version 3.1.18 or greater. See http://dev.mysql.com/doc/refman/5.0/en/connector-j.html for documentation and then http://dev.mysql.com/downloads/connector/j/ to download.

The error message I was getting before upgrading the mysql jdbc connector was:

java.sql.SQLException: Server connection failure during transaction. Due to underlying exception: ‘java.sql.SQLException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ” at line 1′.

** BEGIN NESTED EXCEPTION **

java.sql.SQLException
MESSAGE: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ” at line 1

STACKTRACE:

java.sql.SQLException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ” at line 1
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2921)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1570)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1665)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2972)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2902)
at com.mysql.jdbc.Statement.executeUpdate(Statement.java:929)
at com.mysql.jdbc.Connection.setSessionVariables(Connection.java:5077)
at com.mysql.jdbc.Connection.initializePropsFromServer(Connection.java:3680)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:2684)
at com.mysql.jdbc.Connection.<init>(Connection.java:1474)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:264)
at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:135)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137)
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014)
at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32)
at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)

This is in the babble category tagged as ,

Add a comment »

For some reason Java doesn’t like to obey http forwards if the protocol is changing. It has been this way for a while: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4620571.  So when I was trying to load https://modules.openmrs.org that had an apache redirectMatch to http://modules.openmrs.org, I would get the html for the 301 redirect instead of the source of http://modules.openmrs.org.

I was lucky that I have control over the server and could change the http/https to a simply proxy instead of redirecting.  If I didn’t, I would have had to catch the protocol change and refetch the new url.

It took me a while to find an answer for this because these keywords didn’t give many results on google: URLConnection HttpURLConnection openConnection() connect() getInputStream() Apache redirectMatch 301 302.

This is in the babble category tagged as ,

Add a comment »

For some reason Ubuntu regressed a bit in the multiple monitor department between Hardy and Intrepid.  Before upgrading I was able to dock my Thinkpad and easily switch screens using fn-f7 to switch resolutions just like in the Windows World.  After upgrading function f7 usually didn’t work so I had to start just shutting down the computer (or at least control-alt-backspacing to restart x) if I switched between external monitor and the laptop monitor.

I recently discovered “grandr” and its capabilities.  It worked more often than Ubuntu’s Screen Resolution program…but I had to use my mouse and see the screen to do so.  This meant that I had to the lcd before I did a stand by or took the laptop off the dock.

I then discovered the command line “xrandr” program.  It let me set up some scripts to switch the screen resolution.

  • Use open source ATI driver (not fglrx)
  • Set up your terminal to launch with a keyboard shortcut (System–>Preferences–>Keyboard Shortcuts)
  • Figure out what randr calls the lcd and vga video card outputs with just xrandr
  • Create ./lcd.sh and ./vga.sh and set them to be executable with chmod +x

lcd.sh:

/usr/bin/xrandr –screen LVDS –auto

vga.sh:

/usr/bin/xrandr –screen “VGA-0″ –auto
/bin/sleep 4
/usr/bin/xrandr –screen LVDS –output LVDS –off


Now after undocking I don’t need to be able to see the screen to turn on the lcd.  I just type Alt-t to bring up the terminal, then ./lcd.sh and the lcd turns on. :-)   Jaunty is supposed to have improved monitor support, so I’m looking forward to its release.

This is in the babble category tagged as , ,

Add a comment »