当我使用Jar文件和命令提示符时,jdbc有问题
|
我使用JDeveloper开发JDBC程序,现在我的程序完成了,我想单独运行它。当我尝试从命令提示符运行我的jar文件时遇到问题。
当我使用命令提示符运行我的程序时,我的程序无法连接到我的oracle数据库!但是当我使用JDeveloper IDE时,没有任何问题!
我的IDE运行以下命令:
javaw.exe -client -classpath C:\\JDeveloper\\mywork\\SourceManagmentTools\\.adf;C:\\JDeveloper\\mywork\\SourceManagmentTools\\Client\\classes;C:\\Oracle\\Middleware\\jdeveloper\\jdev\\lib\\jdev-rt.jar;C:\\JDeveloper\\mywork\\SourceManagmentTools\\Client\\ojdbc14.jar;C:\\JDeveloper\\mywork\\SourceManagmentTools\\Client\\quaqua-filechooser-only.jar;C:\\JDeveloper\\mywork\\SourceManagmentTools\\Client\\quaqua-test.jar;C:\\JDeveloper\\mywork\\SourceManagmentTools\\Client\\quaqua.jar;C:\\JDeveloper\\mywork\\SourceManagmentTools\\Client\\swing-layout.jar;C:\\JDeveloper\\mywork\\SourceManagmentTools\\Client\\image;C:\\JDeveloper\\mywork\\SourceManagmentTools\\Client\\lipstikLF-1.1.jar -Djavax.net.ssl.trustStore=C:\\Oracle\\Middleware\\wlserver_10.3\\server\\lib\\DemoTrust.jks Main.GUI.SmRun amir
我使用以下命令:
Java -jar smt.jar amir
当我运行IDE命令时,没有任何问题,一切正常,请您帮帮我吗? (我的程序正在运行并且正在工作,只是我无法从数据库中获取数据)
当我尝试从数据库中选择时,出现以下错误...
C:\\JDeveloper\\mywork\\SourceManagmentTools\\Client\\deploy>java -jar smt.jar amir
[Ljava.lang.StackTraceElement;@7a148bd3[Ljava.lang.StackTraceElement;@51b48197[L
java.lang.StackTraceElement;@58ecb281[Ljava.lang.StackTraceElement;@25fa1bb6[Lja
va.lang.StackTraceElement;@62da3a1e[Ljava.lang.StackTraceElement;@15f48262[Ljava
.lang.StackTraceElement;@7dc05ffd[Ljava.lang.StackTraceElement;@15e232b5[Ljava.l
ang.StackTraceElement;@36baa466[Ljava.lang.StackTraceElement;@177f409c[Ljava.lan
g.StackTraceElement;@2b8bbc5a[Ljava.lang.StackTraceElement;@62facf0b[Ljava.lang.
StackTraceElement;@5ff3ce5c[Ljava.lang.StackTraceElement;@561777b1Exception in t
hread \"AWT-EventQueue-0\" java.lang.NullPointerException
at Main.Database.SmDatabase.selectCustomers(SmDatabase.java:151)
at Main.GUI.SmCreateProject.this_windowOpened(SmCreateProject.java:109)
at Main.GUI.SmCreateProject.access$000(SmCreateProject.java:30)
at Main.GUI.SmCreateProject$1.windowOpened(SmCreateProject.java:58)
at java.awt.AWTEventMulticaster.windowOpened(Unknown Source)
at java.awt.Window.processWindowEvent(Unknown Source)
at javax.swing.JDialog.processWindowEvent(Unknown Source)
at java.awt.Window.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown
Source)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown
Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown
Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
mydatabase类的一部分:
public class SmDatabase {
Connection conn = null;
public SmDatabase() {
try {
String drivername = \"oracle.jdbc.driver.OracleDriver\";
Class.forName(drivername);
String ServerName = \"127.0.0.1\";
String ProtNumber = \"1521\";
//String sid = \"DEVP0\";
String sid = \"cms\";
String url =
\"jdbc:oracle:thin:@\" + ServerName + \":\" + ProtNumber + \":\" +
sid;
//String Username = \"PENTAVCB\";
//String Password = \"pentasoft123\";
String Username = \"cmsuser\";
String Password = \"pass\";
conn = DriverManager.getConnection(url, Username, Password);
} catch (ClassNotFoundException e) {
System.out.print(e.getStackTrace());
} catch (SQLException se) {
System.out.print(se.getStackTrace());
}
}
public Vector<String[]> selectCustomers(String command) {
ResultSet resultSet = null;
Statement statement;
Vector<String[]> customerName = new Vector<String[]>();
try {
statement = conn.createStatement();
LINE151 resultSet = statement.executeQuery(command);
while (resultSet.next()) {
String[] temp = new String[2];
temp[0] = resultSet.getString(\"V_CUST_NAME\");
temp[1] = resultSet.getString(\"V_CUST_CODE\");
customerName.add(temp);
}
resultSet.close();
statement.close();
// conn.close();
} catch (SQLException e) {
System.out.println(e.getStackTrace());
}
return customerName;
}
没有找到相关结果
已邀请:
4 个回复
壤欠攻混
将比produce5ѭ产生更多有用的输出。我会更改它在您的应用程序中出现的所有位置,然后重试。
很可能会引发您无法正确打印的异常,从而产生\“ [Ljava.lang.StackTraceElement ... \”垃圾。
课刊灭似
我看不到在哪里调用SmDatabase来设置conn。是从别的地方叫吗?呼叫是否捕获异常并且不显示错误消息?
辰炔诚薯
瓜唱鬼
我想我们在项目中使用的那些库也需要运行,但是我不确定,我只是建议这项工作
如果有人在此帖子中添加一些有用的信息,我将非常感谢