<%@ page import="
weblogic.db.jdbc.*,
weblogic.html.*,
java.sql.*,
javax.sql.*,
javax.naming.*,
java.util.Properties
" %>
<%
Connection conn = null;
Context ctx = null; //look up jndi name
try {
String url = "t3://localhost:7001";
String user = null;
String password = null;
Properties properties = null;
try {
properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
properties.put(Context.PROVIDER_URL, url);
if (user != null) {
properties.put(Context.SECURITY_PRINCIPAL, user);
properties.put(Context.SECURITY_CREDENTIALS, password == null ? "" : password);
} ctx = new InitialContext(properties);
}
catch(Exception e) {
throw e;
} DataSource ds = null;
ds = (DataSource)ctx.lookup("ejbPool");
conn = ds.getConnection("system", "11111111");
//自己把密码改一下 // Fetch all records from the database in a TableDataSet
DataSet dSet = new TableDataSet(conn, "accounts").fetchRecords();
TableElement tE = new TableElement(dSet);
tE.setBorder(1);
out.print(tE);
} catch (SQLException sqle) {
out.print("Sorry, the database is not available.");
out.print("Exception: " + sqle);
} catch (Exception e) {
out.print("Exception occured: " + e);
} finally {
if(conn != null)
try {
conn.close();
} catch(SQLException sqle) {}
}
%>
weblogic.db.jdbc.*,
weblogic.html.*,
java.sql.*,
javax.sql.*,
javax.naming.*,
java.util.Properties
" %>
<%
Connection conn = null;
Context ctx = null; //look up jndi name
try {
String url = "t3://localhost:7001";
String user = null;
String password = null;
Properties properties = null;
try {
properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
properties.put(Context.PROVIDER_URL, url);
if (user != null) {
properties.put(Context.SECURITY_PRINCIPAL, user);
properties.put(Context.SECURITY_CREDENTIALS, password == null ? "" : password);
} ctx = new InitialContext(properties);
}
catch(Exception e) {
throw e;
} DataSource ds = null;
ds = (DataSource)ctx.lookup("ejbPool");
conn = ds.getConnection("system", "11111111");
//自己把密码改一下 // Fetch all records from the database in a TableDataSet
DataSet dSet = new TableDataSet(conn, "accounts").fetchRecords();
TableElement tE = new TableElement(dSet);
tE.setBorder(1);
out.print(tE);
} catch (SQLException sqle) {
out.print("Sorry, the database is not available.");
out.print("Exception: " + sqle);
} catch (Exception e) {
out.print("Exception occured: " + e);
} finally {
if(conn != null)
try {
conn.close();
} catch(SQLException sqle) {}
}
%>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货