当前位置: 代码迷 >> Java相关 >> SQL与ORACLE9i的有关问题
  详细解决方案

SQL与ORACLE9i的有关问题

热度:4890   发布时间:2013-02-25 21:48:51.0
SQL与ORACLE9i的问题
原来用java swing做的一个程序,数据库用的是sql server2005 ,现在想改成用oracle9i,连接已经成功,但是在下面的代码中提示有问题,是不是sql 和oracel 的语句有区别?请高手指点。我应该如何改。下面是用sql server2005数据库时的代码。


if (button == pane.surebtnl ) {

String sid = pane.numbertex.getText().trim();
String sps = new String(pane.passtex.getPassword()).trim();
String sql = "select * from manager where mname='" + sid
+ "' and mpassword='" + sps + "'and mdel=1";
ResultSet rs;
boolean isexist = false;
try {
rs = db.getResult(sql);
isexist = rs.first();
} catch (SQLException w) {
System.out.println(w);
}
// 判断密码是否正确
if (!isexist) {
JOptionPane.showMessageDialog(null, "用户名不存在,或密码不正确");
pane.passtex.setText("");
return;
} else {
frame.miLedit.setEnabled(true);
frame.muScand.setEnabled(true);
frame.muEquipment.setEnabled(true);
frame.muUser.setEnabled(true);
frame.muFile.setEnabled(true);
frame.jTree.setEnabled(true);
pane.numbertex.setText("");
pane.passtex.setText("");

}

}


这是提示错误的信息。返回空
getResult------java.lang.NullPointerException
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at contorl.LoginControl.actionPerformed(LoginControl.java:38)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:6216)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
at java.awt.Component.processEvent(Component.java:5981)
at java.awt.Container.processEvent(Container.java:2041)
at java.awt.Component.dispatchEventImpl(Component.java:4583)
at java.awt.Container.dispatchEventImpl(Container.java:2099)
at java.awt.Component.dispatchEvent(Component.java:4413)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4556)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4220)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4150)
at java.awt.Container.dispatchEventImpl(Container.java:2085)
at java.awt.Window.dispatchEventImpl(Window.java:2475)
at java.awt.Component.dispatchEvent(Component.java:4413)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)


------解决方案--------------------------------------------------------
上述代码sql没问题。。null是因为连接数据库问题。。。

看看oracle的jar包有没有放到lib目录?连接url及驱动有没有写正确。。?都检查一遍
  相关解决方案