VE-runtime-1.2.3_jem.zip
GEF-runtime-3.2.zip
emf-sdo-runtime-2.2.0.zip
eclipse-SDK-3.2.2-win32.zip
我用这四个版本
制作gui时为什么不太稳定
因为都是新下的preferences中有什么需要设置下,去掉不需要的功能,能让eclipse更好的运行
还有就是在写连接数据库的代码时像这样的函数
private void showFirst(){
String sql1="SELECT * FROM accountsubject WHERE accountcode='"+jTable.getValueAt(0, 0)+"'";
rs=dB.executeQuery(sql1);
try {
if(rs.next()){
showSubject(rs);
}
rs.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}在编辑过程中就会弹出连接失败的对话框
就是下面查询函数的JOptionPane.showMessageDialog(null,"更新数据库失败6!","错误提示",JOptionPane.ERROR_MESSAGE);
语句
public void executeUpdate(String sql){
try{
if(con == null)
close();
connect();
stmt.executeUpdate(sql);
//JOptionPane.showMessageDialog(null,"更新成功!","提示",JOptionPane.INFORMATION_MESSAGE);
}
catch(Exception e){
JOptionPane.showMessageDialog(null,"更新数据库失败6!","错误提示",JOptionPane.ERROR_MESSAGE);
e.printStackTrace();
}finally{
close();
}
}
程序运行时一切正常的,为什么编辑的时候会出这个错误
解决方案 »
- 父类方法通过反射取属性,是子类还是父类的属性?
- 内存分配问题
- (Graphics2D)g是哈子意思哦?
- 使用system.in的问题
- 求救:jsp访问mysql可以多库查询吗,即一次从2个以上库中查询数据
- 不知道具体会发生哪个异常,只要程序出错,就捕捉异常,该捕捉哪个异常?
- 加载图象的问题!!!!求你了,告诉我吧!!!
- 帮帮我!!!!!!!!
- eclipse和DOM-4j解析xml文件时候出现java.lang.Exception: No runnable methods
- Java的这种类怎么理解?实例化后在内存上如何体现?
- 如何设置java程序在按下显示桌面时还能在桌面上显示,就好像桌面上的图标一样
- 请问一个数据库问题
close();
close();
connect();
stmt.executeUpdate(sql);
//JOptionPane.showMessageDialog(null,"更新成功!","提示",JOptionPane.INFORMATION_MESSAGE);
} zhe li neng zhi xing ma ???
JOptionPane.showMessageDialog(null,"更新数据库失败6!","错误提示",JOptionPane.ERROR_MESSAGE);
的对话框 我也没有运行
谢谢各位了 帮我看看数据库的这个类有什么问题吧,应为还在学习,没有专业的编程经验,我的这个类我觉得问题不小
希望各位给我指点下import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;import javax.sql.rowset.CachedRowSet;
import javax.swing.JOptionPane;
public class DBOperation {
// String url = "jdbc:mysql://localhost/LibraryManagementSystem"; // @jve:decl-index=0:
// String url = "jdbc:mysql://localhost:3306/LibraryManagementSystem?useUnicode=true&characterEncoding=GB2312"; // @jve:decl-index=0:
String url=null;
String user = null; // @jve:decl-index=0: String psd = null; // @jve:decl-index=0:
Statement stmt=null;
String host=null;
Connection con=null;
ResultSet resultset=null;
CachedRowSet rowSet=null;
Configuration cf = new Configuration(System.getProperty("user.dir")+"\\config.properties");
DBOperation(){
user = cf.getValue("user");
psd = cf.getValue("password");
host=cf.getValue("host");
url="jdbc:mysql://"+host+":3306/financialmanagementsystem?useUnicode=true&characterEncoding=GB2312";
try {
Class.forName("org.gjt.mm.mysql.Driver");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
JOptionPane.showMessageDialog(null,"加载数据库驱动器失败!","错误提示",JOptionPane.ERROR_MESSAGE);
}
}
//建立连接
void connect(){ try {
con = DriverManager.getConnection(url,user,psd);
stmt = con.createStatement();
} catch (SQLException e) {
// TODO Auto-generated catch block
JOptionPane.showMessageDialog(null,"连接数据库失败!","错误提示",JOptionPane.ERROR_MESSAGE);
}
}
/**
* 关闭连接
*
*/
public void close(){
try{ if(con != null) con.close();
if(stmt != null) stmt.close();
}catch(Exception e){
JOptionPane.showMessageDialog(null,"关闭数据库连接失败!","错误提示",JOptionPane.ERROR_MESSAGE);
}
}
//查询函数
public CachedRowSet executeQuery(String sql){
try{
rowSet = new com.sun.rowset.CachedRowSetImpl();
if(con==null)
close();
connect();
resultset = stmt.executeQuery(sql);
rowSet.populate(resultset);
}
catch(Exception e){
//JOptionPane.showMessageDialog(null,"数据库查询失败5!","错误提示",JOptionPane.ERROR_MESSAGE);
e.printStackTrace();
}finally{
close();
}
return rowSet;
}
//更新函数
public void executeUpdate(String sql){
try{
if(con == null)
close();
connect();
stmt.executeUpdate(sql);
//JOptionPane.showMessageDialog(null,"更新成功!","提示",JOptionPane.INFORMATION_MESSAGE);
}
catch(Exception e){
// JOptionPane.showMessageDialog(null,"更新数据库失败6!","错误提示",JOptionPane.ERROR_MESSAGE);
e.printStackTrace();
}finally{
close();
}
}
}
close();
connect();
stmt.executeUpdate(sql);
if(con==null)
close();
connect();
resultset = stmt.executeQuery(sql); 这两处的close()我知道放的很不是地方,可是不放的话,有时回提示stmt没有关闭