BF [ 1885260 ] MPAttributeLookup: throws SQLException sometimes
* reorganize imports * commented out unused variables
This commit is contained in:
parent
0ad10e90d3
commit
e4152c7582
|
@ -16,17 +16,27 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package org.compiere.model;
|
package org.compiere.model;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.Serializable;
|
||||||
import java.sql.*;
|
import java.sql.PreparedStatement;
|
||||||
import java.util.*;
|
import java.sql.ResultSet;
|
||||||
import java.util.logging.*;
|
import java.util.ArrayList;
|
||||||
import org.compiere.util.*;
|
import java.util.Properties;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import org.compiere.util.CLogMgt;
|
||||||
|
import org.compiere.util.DB;
|
||||||
|
import org.compiere.util.DisplayType;
|
||||||
|
import org.compiere.util.KeyNamePair;
|
||||||
|
import org.compiere.util.NamePair;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Product Attribute Lookup Model (not Cached)
|
* Product Attribute Lookup Model (not Cached)
|
||||||
*
|
*
|
||||||
* @author Jorg Janke
|
* @author Jorg Janke
|
||||||
* @version $Id: MPAttributeLookup.java,v 1.2 2006/07/30 00:58:38 jjanke Exp $
|
* @version $Id: MPAttributeLookup.java,v 1.2 2006/07/30 00:58:38 jjanke Exp $
|
||||||
|
*
|
||||||
|
* @author Teo Sarca, SC ARHIPAC SERVICE SRL
|
||||||
|
* <li>BF [ 1885260 ] MPAttributeLookup: throws SQLException sometimes
|
||||||
*/
|
*/
|
||||||
public class MPAttributeLookup extends Lookup
|
public class MPAttributeLookup extends Lookup
|
||||||
implements Serializable
|
implements Serializable
|
||||||
|
@ -40,13 +50,11 @@ public class MPAttributeLookup extends Lookup
|
||||||
public MPAttributeLookup(Properties ctx, int WindowNo)
|
public MPAttributeLookup(Properties ctx, int WindowNo)
|
||||||
{
|
{
|
||||||
super(DisplayType.TableDir, WindowNo);
|
super(DisplayType.TableDir, WindowNo);
|
||||||
m_ctx = ctx;
|
// m_ctx = ctx;
|
||||||
} // MPAttribute
|
} // MPAttribute
|
||||||
|
|
||||||
/** Properties */
|
// /** Properties */
|
||||||
private Properties m_ctx;
|
// private Properties m_ctx;
|
||||||
/** Statement */
|
|
||||||
private PreparedStatement m_pstmt = null;
|
|
||||||
/** No Instance Value */
|
/** No Instance Value */
|
||||||
private static KeyNamePair NO_INSTANCE = new KeyNamePair (0,"");
|
private static KeyNamePair NO_INSTANCE = new KeyNamePair (0,"");
|
||||||
|
|
||||||
|
@ -101,17 +109,16 @@ public class MPAttributeLookup extends Lookup
|
||||||
if (M_AttributeSetInstance_ID == 0)
|
if (M_AttributeSetInstance_ID == 0)
|
||||||
return NO_INSTANCE;
|
return NO_INSTANCE;
|
||||||
//
|
//
|
||||||
// Statement
|
|
||||||
if (m_pstmt == null)
|
|
||||||
m_pstmt = DB.prepareStatement("SELECT Description "
|
|
||||||
+ "FROM M_AttributeSetInstance "
|
|
||||||
+ "WHERE M_AttributeSetInstance_ID=?", null);
|
|
||||||
//
|
|
||||||
String Description = null;
|
String Description = null;
|
||||||
|
PreparedStatement pstmt = null;
|
||||||
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
m_pstmt.setInt(1, M_AttributeSetInstance_ID);
|
pstmt = DB.prepareStatement("SELECT Description "
|
||||||
ResultSet rs = m_pstmt.executeQuery();
|
+ "FROM M_AttributeSetInstance "
|
||||||
|
+ "WHERE M_AttributeSetInstance_ID=?", null);
|
||||||
|
pstmt.setInt(1, M_AttributeSetInstance_ID);
|
||||||
|
rs = pstmt.executeQuery();
|
||||||
if (rs.next())
|
if (rs.next())
|
||||||
{
|
{
|
||||||
Description = rs.getString(1); // Description
|
Description = rs.getString(1); // Description
|
||||||
|
@ -123,12 +130,16 @@ public class MPAttributeLookup extends Lookup
|
||||||
Description = "";
|
Description = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rs.close();
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, "get", e);
|
log.log(Level.SEVERE, "get", e);
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
DB.close(rs, pstmt);
|
||||||
|
rs = null; pstmt = null;
|
||||||
|
}
|
||||||
if (Description == null)
|
if (Description == null)
|
||||||
return null;
|
return null;
|
||||||
return new KeyNamePair (M_AttributeSetInstance_ID, Description);
|
return new KeyNamePair (M_AttributeSetInstance_ID, Description);
|
||||||
|
@ -140,16 +151,6 @@ public class MPAttributeLookup extends Lookup
|
||||||
*/
|
*/
|
||||||
public void dispose()
|
public void dispose()
|
||||||
{
|
{
|
||||||
try
|
|
||||||
{
|
|
||||||
if (m_pstmt != null)
|
|
||||||
m_pstmt.close();
|
|
||||||
}
|
|
||||||
catch (SQLException e)
|
|
||||||
{
|
|
||||||
//no need to log close exception
|
|
||||||
//log.log(Level.SEVERE, "dispose", e);
|
|
||||||
}
|
|
||||||
log.fine("");
|
log.fine("");
|
||||||
super.dispose();
|
super.dispose();
|
||||||
} // dispose
|
} // dispose
|
||||||
|
|
Loading…
Reference in New Issue