源码如下:package mogulsystem;
import java.sql.*;
/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2003</p>
 * <p>Company: </p>
 * @author unascribed
 * @version 1.0
 */public class mogul_data {
  String sDBDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
  String sConnStr = "jdbc:odbc:moguldatabase";
 Connection conn = null;
  ResultSet rs = null;
  public mogul_data() {
    try
{
      Class.forName(sDBDriver);
        
}
catch(java.lang.ClassNotFoundException e)
{
System.err.println("mogul_data(): " + e.getMessage());
}
  }
  public void executeInsert(String sql)
  {
  try
  {
      conn = DriverManager.getConnection(sConnStr);    
    Statement stmt = conn.createStatement();
      stmt.executeUpdate(sql);
  }
  catch(SQLException ex)
  {   
  System.err.println("mogul_data.executeUpdate:"+ex.getMessage());
  }
  }
  public ResultSet executeQuery(String sql)
  {
  rs = null;
  try
  {
          conn = DriverManager.getConnection(sConnStr);    
    Statement stmt = conn.createStatement();
    rs = stmt.executeQuery(sql);
  }
  catch(SQLException ex)
  {   
  System.err.println("mogul_data.executeQuery:"+ex.getMessage());
  }
  return rs;
  }  public void executeDelete(String sql)
  {
  try
  {
          conn = DriverManager.getConnection(sConnStr);    
          Statement stmt = conn.createStatement();
          stmt.executeUpdate(sql);
  }
  catch(SQLException ex)
  {   
  System.err.println("mogul_data.executeDelete:"+ex.getMessage());
  }
}
}

解决方案 »

  1.   

    在JBuilder7左下方的语法栏中出现如下错误警告。第一类:
    illegal character at line 17
    如Connection、Class、Statement、conn、SQLException等处报此错误
    第二类:
    Malformed expression at line 26
    如 Class.forName(sDBDriver);处报此错误
      

  2.   

    Connection conn = null;//Here is the line 17, at the first column is a double bytes character.And maybe you copied the code from some book(such as *.doc), there are a Chinese space at the column 1 of this line, and the other errors are the same.Replaced all the Chinese space by the editor, then there will be no error.
      

  3.   

    很明显你没有配置ODBC数据源吧
      

  4.   

    用这个代码:
    package mydate;
    import java.lang.*;
    import java.sql.*;
    public class mydb
    {
        String sDBDriver="sun.jdbc.odbc.JdbcOdbcDriver";
        String sConnStr="jdbc:odbc:chat";
        Connection conn=null;
        Statement stmt=null;
        ResultSet rs=null;
        public mydb()
        {
            try
            {
                Class.forName(sDBDriver);
            }
            catch(ClassNotFoundException e)
            {
                System.err.println("mydb:"+e.getMessage());
            }
        }
        public ResultSet executeQuery(String sql)
        {
            try
            {
                conn=DriverManager.getConnection(sConnStr);
                stmt=conn.createStatement();
                rs=stmt.executeQuery(sql);
            }
            catch(SQLException ex)
            {
                System.err.println("aq.executeQuery:"+ex.getMessage());
            }
            return rs;
        }
        public void executeUpdate(String sql)
        {
            try
            {
                conn=DriverManager.getConnection(sConnStr);
                stmt=conn.createStatement();
                stmt.executeUpdate(sql);
            }
            catch(SQLException ex)
            {
                System.err.println("aq.executeUpdate:"+ex.getMessage());
            }
            
        }
    }
      

  5.   

    你的数据库没有密码??加上吧 这个bean是自己写的还是copy的 我好像认识
      

  6.   

    是copy的错误,你重新写过就可以了
      

  7.   

    你的问题看起是没有写import java.sql.*;但你还写了。关注!