This Domain(Admin5.com) is for Sale:

Velocity 的应用示例

时间:2007-10-22  来源:不详  作者:林子

private static void initJavaMail()

{

}

public static Connection getDatabaseConnection()

{

Connection con = null;

try

{

InitialContext initCtx = new InitialContext();

javax.naming.Context context = (javax.naming.Context) initCtx.lookup("java:comp/env");

javax.sql.DataSource ds = (javax.sql.DataSource) context.lookup("jdbc/TestDB");

//Utilities.debugPrintln("ds = " ds);

con = ds.getConnection();

}

catch (Exception e)

{

Utilities.debugPrintln("Exception = " e.getMessage());

return null;

}

//Utilities.debugPrintln("con = " con);

return con;

}

public static java.sql.ResultSet excuteDbQuery(Connection con, String sql,Object[] parameters)

{

//Exception err = null;

//Utilities.debugPrintln("excuteDbQuery" parameters[0] " ,sql=" sql);

try

{

java.sql.PreparedStatement ps = con.prepareStatement(sql);

for (int i = 0;

i <

parameters.length;

i )

{

processParameter(ps, i 1, parameters[i]);

}

return ps.executeQuery();

看完这篇,您有何感觉呢?

文章评论

共有位Admini5网友发表了评论 查看完整内容

24小时热门信息