lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

I've installed MySql Proxy and Lua, on a linux server and would like to access some Java code from MySql Proxy, using its Lua support. Specifically I'm interested in using a hash function using bit shift operations.
Starting MySql Proxy, giving it a Lua script to use, can be done like this:
>mysql-proxy --proxy-lua-script=/tmp/mysql-proxy-0.6.0/lib/lua-java-test.lua
lua-java-test.lua script contains this:
>obj = luajava.newInstance("java.lang.Object")
>-- obj is now a reference to the new object created and any of its methods can be accessed.
Then sending queries to the MySql proxy activates the Lua code. But the above code causes errors like these:
>(lua-error) [/tmp/mysql-proxy-0.6.0/lib/lua-java-test.lua]
>/tmp/mysql-proxy-0.6.0/lib/lua-java-test.lua:1: attempt to index global 'luajava' (a nil value)
I installed LuaJava, but I'm not sure it's appropriate for what I need. All LuaJava examples I've googled start a java program that loads a Lua script which then references a Java object. This doesn't really apply since I don't want to start from a Java app. Is there any way to reference a Java object from the Lua module used by MySql proxy without loading a java process into memory first?
Would writing the hash function in C and adding it to the Lua source code be a better course of action? Do I need to compile a module into the Lua libraries that MySql Proxy is using?
Any suggestions are appreciated.
I installed Lua using the following:
tar -zxpf lua-5.1.2.tar.gz
cd lua-5.1.2
cp src/Makefile src/Makefile.bak
vi src/Makefile # add -fPIC to CFLAGS
make linux
make install