Java开发网 |
注册 |
登录 |
帮助 |
搜索 |
排行榜 |
发帖统计
|
您没有登录 |
» Java开发网 » Database/JDBC/SQL/JDO/Hibernate
» Oracle
打印话题 寄给朋友 订阅主题 |
作者 | java.lang.NullPointerException错误 |
feetch
发贴: 1 积分: 0 |
于 2009-04-21 22:04
我公司服务器用能正常连接,我自己装机配置后出现下面错误 运行环境 tomcat5.0+jsdk+oracle8 type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception org.apache.jasper.JasperException org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:372) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) root cause java.lang.NullPointerException org.apache.jsp.login_jsp._jspService(login_jsp.java:68) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs. 代码如下,有 db.properties文件 drivers=oracle.jdbc.driver.OracleDriver logfile=F:\Tomcat 5.0\\webapps\\sapoa\\log\\log.txt wf_count=F:\Tomcat 5.0\\webapps\\sapoa\\txt\\wf_count.txt info_count=F:\Tomcat 5.0\\webapps\\sapoa\\txt\\info_count.txt message_count=F:\Tomcat 5.0\\webapps\\sapoa\\message\\count.txt supplier_count=F:\Tomcat 5.0\\webapps\\sapoa\\supplier\\count.txt #localhost orcl 10.40.1.5 eglobal # utic.url=jdbc:oracle:thinlocalhost:1521:finemost #utic.user=finemost #utic.password=password #utic.maxconn=50 # info.url=jdbc:oracle:thinlocalhost:1521:finemost #info.user=finemost #info.password=password #info.maxconn=50 #utic.url=jdbc:oracle:thinlocalhost:1521:ora8 #utic.user=system #utic.password=manager #utic.maxconn=1000 #info.url=jdbc:oracle:thinlocalhost:1521:ora8 #info.user=sapoa #info.password=test #info.maxconn=1000 utic.url=jdbc:oracle:thinlocalhost:1521:websap utic.user=system utic.password=manager utic.maxconn=5000 info.url=jdbc:oracle:thinlocalhost:1521:websap info.user=system info.password=manager info.maxconn=5000 utic_basic.java // Decompiled by Jad v1.5.8f. Copyright 2001 Pavel Kouznetsov. // Jad home page: http://www.kpdus.com/jad.html // Decompiler options: packimports(3) fieldsfirst splitstr(nl) ansi nonlb space // Source File Name: utic_basic.java package utic.basic; import java.io.PrintStream; import java.sql.*; import java.util.*; // Referenced classes of package utic.basic: // cn, DBConnectionManager public class utic_basic { private DBConnectionManager dbconn_pool; Connection con; private Statement stmt; private ResultSet r_result; public utic_basic() { con = null; stmt = null; r_result = null; dbconn_pool = DBConnectionManager.getInstance(); con = dbconn_pool.getConnection("utic"); if (con == null) { System.out.println("Can't Get The Connection,In Pool of Utic!"); return; } try { stmt = con.createStatement(1005, 1007); } catch (Exception exception) { exception.printStackTrace(); System.out.println("Error CreateStatement At utic_basic()" + exception.toString()); } } public ResultSet findResultBySql(String s) { try { r_result = stmt.executeQuery; } catch (Exception exception) { exception.printStackTrace(); } return r_result; } public void commonInit() { } public void stmtclose() { try { stmt.close(); dbconn_pool.freeConnection("utic", con); } catch (Exception exception) { exception.printStackTrace(); System.out.println("In stmtclose:" + exception.toString()); } } public boolean insertToDb(String s) { boolean flag = false; try { flag = stmt.execute; } catch (Exception exception) { exception.printStackTrace(); } return flag; } public int updateDb(String s) { int i = 0; try { i = stmt.executeUpdate; } catch (Exception exception) { exception.printStackTrace(); } return i; } public Hashtable page_display(Hashtable hashtable, Hashtable hashtable1) { Hashtable hashtable2 = new Hashtable(); Vector vector = new Vector(); String s = ""; String s2 = ""; Object obj = null; commonInit(); cn cn1 = new cn(); String s4 = ""; Vector vector2 = new Vector(); boolean flag = false; try { String s3; for (Enumeration enumeration = hashtable.keys(); enumeration.hasMoreElements(); hashtable2.put(s3, vector2)) { s3 = enumeration.nextElement().toString(); Vector vector1 = (Vector)hashtable.get(s3); String s1 = (String)hashtable1.get(s3); String s5 = "select * from " + s3 + s1; ResultSet resultset = stmt.executeQuery(s5); vector2.removeAllElements(); while (resultset.next()) { for (int i = 0; i < vector1.size(); i++) vector2.add(cn.cn(resultset.getString(vector1.elementAt.toString()))); } } } catch (Exception exception) { exception.printStackTrace(); } return hashtable2; } public Hashtable getValueByIf(String s, Vector vector, String s1) { Hashtable hashtable = new Hashtable(); String s2 = ""; s2 = "select * from " + s + s1; Object obj = null; commonInit(); cn cn1 = new cn(); try { boolean flag = false; String s3 = ""; ResultSet resultset = stmt.executeQuery(s2); if (resultset.next()) { for (int i = 0; i < vector.size(); i++) { String s4 = vector.elementAt.toString(); hashtable.put(s4, cn.cn(resultset.getString(s4))); } } else { for (int j = 0; j < vector.size(); j++) { String s5 = vector.elementAt(j).toString(); hashtable.put(s5, ""); } } } catch (Exception exception) { exception.printStackTrace(); } return hashtable; } public boolean deleteColumn(String s) { boolean flag = false; try { flag = stmt.execute; } catch (Exception exception) { exception.printStackTrace(); } return flag; } } // Decompiled by Jad v1.5.8f. Copyright 2001 Pavel Kouznetsov. // Jad home page: http://www.kpdus.com/jad.html // Decompiler options: packimports(3) fieldsfirst splitstr(nl) ansi nonlb space // Source File Name: DBConnectionManager.java package utic.basic; import java.io.*; import java.sql.*; import java.util.*; public class DBConnectionManager { class DBConnectionPool { private int checkedOut; private Vector freeConnections; private int maxConn; private String name; private String password; private String url; private String user; public synchronized void freeConnection(Connection connection) { freeConnections.addElement(connection); checkedOut--; notifyAll(); } public synchronized Connection getConnection() { Connection connection = null; if (freeConnections.size() > 0) { connection = (Connection)freeConnections.firstElement(); freeConnections.removeElementAt(0); try { if (connection.isClosed()) { log("眖硈钡?" + name + "?埃??礚?硈钡"); connection = getConnection(); } } catch (SQLException sqlexception) { log("眖硈钡?" + name + "?埃??礚?硈钡"); connection = getConnection(); } } else if (maxConn == 0 || checkedOut < maxConn) connection = newConnection(); else if (checkedOut > maxConn) System.out.println("硈钡?" + name + "⊿Τ?パ硈钡??硈钡?笷???! " + checkedOut); if (connection != null) checkedOut++; else if (connection == null) System.out.println("??计沮畐笷?processes??! "); return connection; } public synchronized Connection getConnection(long l) { long l1 = (new Date()).getTime(); Connection connection; while ((connection = getConnection()) == null) { try { wait(l); } catch (InterruptedException interruptedexception) { } if ((new Date()).getTime() - l1 >= l) return null; } return connection; } public synchronized void release() { for (Enumeration enumeration = freeConnections.elements(); enumeration.hasMoreElements() { Connection connection = (Connection)enumeration.nextElement(); try { connection.close(); log("闽超硈钡?" + name + "い?硈钡"); } catch (Exception exception) { log(exception, "礚猭闽超硈钡?" + name + "い?硈钡"); } } freeConnections.removeAllElements(); } private Connection newConnection() { Connection connection = null; try { if (user == null) connection = DriverManager.getConnection(url); else connection = DriverManager.getConnection(url, user, password); log("眖硈钡?" + name + "承???穝?硈钡"); } catch (SQLException sqlexception) { log(sqlexception, "礚猭承???硈钡:" + url); return null; } return connection; } public DBConnectionPool(String s, String s1, String s2, String s3, int i) { freeConnections = new Vector(); name = s; url = s1; user = s2; password = s3; maxConn = i; } } private static DBConnectionManager instance; private static int clients; private Vector drivers; private PrintWriter log; private Hashtable pools; public static synchronized DBConnectionManager getInstance() { if (instance == null) instance = new DBConnectionManager(); clients++; return instance; } private DBConnectionManager() { drivers = new Vector(); pools = new Hashtable(); init(); } public void freeConnection(String s, Connection connection) { DBConnectionPool dbconnectionpool = (DBConnectionPool)pools.get; if (dbconnectionpool != null) dbconnectionpool.freeConnection(connection); } public Connection getConnection(String s) { DBConnectionPool dbconnectionpool = (DBConnectionPool)pools.get; if (dbconnectionpool != null) return dbconnectionpool.getConnection(); else return null; } public Connection getConnection(String s, long l) { DBConnectionPool dbconnectionpool = (DBConnectionPool)pools.get; if (dbconnectionpool != null) return dbconnectionpool.getConnection(l); else return null; } public synchronized void release() { if (--clients != 0) return; DBConnectionPool dbconnectionpool; for (Enumeration enumeration = pools.elements(); enumeration.hasMoreElements(); dbconnectionpool.release()) dbconnectionpool = (DBConnectionPool)enumeration.nextElement(); for (Enumeration enumeration1 = drivers.elements(); enumeration1.hasMoreElements() { Driver driver = (Driver)enumeration1.nextElement(); try { DriverManager.deregisterDriver(driver); log("篗?JDBC臱笆祘?" + driver.getClass().getName() + "?猔?!"); } catch (SQLException sqlexception) { log(sqlexception, "礚猭篗???JDBC臱笆祘??猔?" + driver.getClass().getName()); } } } private void createPools(Properties properties) { for (Enumeration enumeration = properties.propertyNames(); enumeration.hasMoreElements() { String s = (String)enumeration.nextElement(); if (s.endsWith(".url")) { String s1 = s.substring(0, s.lastIndexOf(".")); String s2 = properties.getProperty(s1 + ".url"); if (s2 == null) { log("⊿Τ?硈钡?" + s1 + "?﹚URL"); } else { String s3 = properties.getProperty(s1 + ".user"); String s4 = properties.getProperty(s1 + ".password"); String s5 = properties.getProperty(s1 + ".maxconn", "0"); int i; try { i = Integer.valueOf(s5).intValue(); } catch (NumberFormatException numberformatexception) { log("岿粇?程?硈钡计??:" + s5 + ".硈钡?" + s1); i = 0; } DBConnectionPool dbconnectionpool = new DBConnectionPool(s1, s2, s3, s4, i); pools.put(s1, dbconnectionpool); log("Θ?承?硈钡?" + s1); } } } } private void init() { java.io.InputStream inputstream = getClass().getResourceAsStream("/db.properties"); Properties properties = new Properties(); try { properties.load(inputstream); } catch (Exception exception) { System.err.println("ぃ?弄?妮┦ゅン.叫絋玂db.properties?CLASSPATH?﹚?隔畖い!"); return; } String s = properties.getProperty("logfile", "DBConnectionManager.log"); try { log = new PrintWriter(new FileWriter(s, true), true); } catch (IOException ioexception) { System.err.println("礚猭ゴ秨らвゅン:" + s); log = new PrintWriter(System.err); } loadDrivers(properties); createPools(properties); } private void loadDrivers(Properties properties) { String s = properties.getProperty("drivers"); for (StringTokenizer stringtokenizer = new StringTokenizer; stringtokenizer.hasMoreElements() { String s1 = stringtokenizer.nextToken().trim(); try { Driver driver = (Driver)Class.forName(s1).newInstance(); DriverManager.registerDriver(driver); drivers.addElement(driver); log("Θ?猔?JDBC臱笆祘?" + s1); } catch (Exception exception) { log("礚猭猔?JDBC臱笆祘?" + s1 + ",岿粇:" + exception); } } } private void log(String s) { log.println(new Date() + ":" + s); } private void log(Throwable throwable, String s) { log.println(new Date() + ":" + s); throwable.printStackTrace(log); } } |
已读帖子 新的帖子 被删除的帖子 |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |