Files
Work/proto/HistoricRS.java
2024-08-07 09:16:27 -04:00

54 lines
1.0 KiB
Java

package zbi.risk.server.vhi.mapped
public class HistoricDA
{
public List readAll()throws SQLException
{
Statement statement=null;
ResultSet rs=null;
Connection connection=null;
String strQuery=null;
List list=null;
try
{
<classname> <instancename> = new <classname>
connection=getConnection();
statement=connection.createStatement();
list=new ArrayList();
strQuery="select jdjdjd djdjdjd djdjdjd from <tablename>";
rs=statement.executeQuery(strQuery);
while(rs.next())
{
<assign variables>
list.add(<instancename>);
}
return list;
}
finally
{
if(null!=rs)rs.close();
if(null!=statement)statement.close();
}
}
};
private Connection getConnection()throws SQLException
{
try
{
InitialContext jndiCntx=new InitialContext();
DataSource ds=(DataSource)jndiCntx.lookup("java:MailDb");
jndiCntx.close();
return ds.getConnection();
}
catch(NamingException exception)
{
message("[MailEJB::getConnection] Object not found");
throw new EJBException(exception);
}
}