how to insert a Java object into MySQL via ColdFusion
Hi everyone,
I have searched everywhere on the Internet best I can trying to find the answer. Still no result yet. I did find some code for how to insert a Java object into MySQL using pure Java. It goes like this: first you make a connection with the MySQL database by using Connection object. Then you use PreparedStatement object to prepare the sql statement. Then you call its executeUpdate() method. Done! This is how it is done in Java. But I am trying to see if I can do this directly in ColdFusion. Say I have a Java object myJavaOjbect, which implemens Serializable interface already. I want to insert it into java_objects_t table, which contains a column with BLOB type called my_java_data. Then in ColdFusoin I try to do this:
<cfquery name="insertJavaObject" dataSource="#Application.ds#">
INSERT INTO java_objects_t (my_java_data) values (#myJavaObject#)
</cfquery>
This query does not work because #myJavaObject# turn out to be a String object, because it automatically calls its toString() method.
Is there a way to insert a Java object into MySQL database table inside ColdFusion page? Or do I need to use pure Java to do this?
Thank you for helping, everyone!
