How to use ColdFusion datasource from JAVA
Hello, every one:
I'm trying to figure out the way to connect to database from my java data access class by using ColdFusion configured datasource.
But, I have not get any luck.
Here is my test code: Please help.
//Test1.java
import java.sql.*;
public class Test1
{
public static void main(String argv[])
{
try
{
coldfusion.server.DataSourceService dsr = coldfusion.server.ServiceFactory.getDataSourceService();
javax.sql.DataSource ds = dsr.getDatasource("project"); //"project" is a datasource name configured in CF admin
Connection con = ds.getConnection();
/* if connected, do some thing */
}
catch ( Exception e1 )
{
System.out.println(e1.toString());
}
}
}
I have got it compiled.
But when run it, I got the folowing error:
"coldfusion.server.ServiceFactory$ServiceNotAvailableException: The '' service is not available"
Any idea ?
Thanks.
Shiofan
