Java开发网 |
注册 |
登录 |
帮助 |
搜索 |
排行榜 |
发帖统计
|
您没有登录 |
» Java开发网 » Java SE 综合讨论区
» Java与OOP初步
打印话题 寄给朋友 订阅主题 |
作者 | java.lang.NullPointerException |
linqiuppp
发贴: 8 积分: 0 |
于 2005-10-25 00:46
通过编译,但运行时发生这个java.lang.NullPointerException错误! |
作者 | Re:java.lang.NullPointerException [Re:linqiuppp] |
linqiuppp
发贴: 8 积分: 0 |
于 2005-10-25 15:11
我知道错哪了,忘了初始化ArrayList. 谢谢大家! |
作者 | Re:java.lang.NullPointerException [Re:linqiuppp] |
andony756
发贴: 21 积分: 1 |
于 2005-11-28 21:21
谢谢大家的帮助 程序代码请见附件 package com.ctc.forum.db; import java.sql.*; import com.ctc.forum.util.PropertyFileManager; public class DBConnection { public DBConnection() { } public static Connection getConnection() { Connection conn = null; try { PropertyFileManager pm = new PropertyFileManager("config"); String driver = pm.getValue("driver"); Class.forName(driver). newInstance(); String url = pm.getValue("url"); String user = pm.getValue("username"); String password = pm.getValue("password"); conn = DriverManager.getConnection(url, user, password); } catch (SQLException ex) { ex.printStackTrace(); } catch (ClassNotFoundException ex) { ex.printStackTrace(); } catch (IllegalAccessException ex) { ex.printStackTrace(); } catch (InstantiationException ex) { ex.printStackTrace(); } return conn; } public static void main(String[] args) { Connection conn = DBConnection.getConnection(); if (conn != null) { System.out.print("ok"); } } } 770KB attachment's removed. use the one on http://www.cjsdn.net/post/view?bid=10&id=164214
why edited on 2005-11-30 17:48
|
作者 | Re:java.lang.NullPointerException [Re:linqiuppp] |
andony756
发贴: 21 积分: 1 |
于 2005-11-29 20:37
呵呵 为什么我会说我的程序和数据库是没问题的 那是因为完全一样的程序和设置 在我原来的电脑上是能运行的 而现在我只要是与数据库有关的程序都是同样的错误提示 我只是拿以前能运行的例子做测试 请帮我找出原因所在 谢谢 |
作者 | Re:java.lang.NullPointerException [Re:andony756] |
why
問題兒童 总版主 发贴: 4629 积分: 388 |
于 2005-11-30 17:50
andony756 wrote: Okay, now I know, it's jsp. 770KB attachment's removed. (Please don't triple-post your question and attachment) Please continue on http://www.cjsdn.net/post/view?bid=10&id=164214 |
作者 | Re:java.lang.NullPointerException [Re:linqiuppp] |
wangyabing
发贴: 18 积分: 0 |
于 2005-12-29 16:22
I can not run it ,I use JCreator ,please tell me |
已读帖子 新的帖子 被删除的帖子 |
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 |