在二次开发中,有时需要大量的运算时,不想用mboSet对像,想直接操作数据库,为此需要在java得到maximo的数据库联接对像
如下:
import psdi.mbo.*;
import java.sql.*;
import psdi.server.*;
….
{
Mbo mbo = (Mbo)super.getThisMboSet().getMbo();
PreparedStatement sm = null;
try
{
Connection connection = mbo.getMboServer().getDBConnection(mbo.getUserInfo().getConnectionKey());
String sql = "";
sm = connection.prepareStatement(sql);
long rows = sm.executeUpdate();
connection.commit();
if(sm != null)
{
sm.close();
}
}
catch(Exception exception)
{
exception.printStackTrace();
try
{
if(sm != null)
sm.close();
}
catch(SQLException sqlexception1) { }
throw new MXApplicationException("…..") ;
}
finally
{
mbo.getMboServer().freeDBConnection(mbo.getUserInfo().getConnectionKey());
}
}