20.12.03
11:34 (
,
,
,
)
News:
Run java in MySQL. It allows you to write user defined functions in Java which can be used in select/insert/update statemenets.
Sample select: the function test.GreenBar is executed on column1 and column2 of the result set
SELECT: SELECT judf("test/GreenBar", COLUMN1, COLUMN2) FROM foo;
Java Code: all you have to do is to implement public static String exec(String[] args) which will return the new String.
package test;
public class GreenBar {
public static String exec(String[] args) {
StringBuffer buf = new StringBuffer("Green bar (");
buf.append(args.length);
buf.append(") ");
for(int i = 0; i < args.length; i++){
buf.append(", ");
buf.append(args[i]);
}
return buf.toString();
}
// future interface?
public static byte[] exec(byte[][] args) {
return ("green bar " + new String(args[0])).getBytes();
}
}
posted by Jean-Marc Autexier |
0 comments | Permalink | Send to Friends | Google it!
|