下面的java代码为什么生不成class文件
最下面是编译时的问题
import java.sql.*;public class DBSQL {
Connection conn;
Statement stmt;
String strCon;
/**
* 构造函数
*/
public DBSQL() {
conn = null;
stmt = null;
strCon = "jdbc:odbc:soft"; try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch (Exception ex) {
System.err.println("没有找到JDBC-ODBC数据库驱动器");
}
}/**
* 打开数据库,准备操作
*/
public void openDB() {
try {
//连接数据库
conn = DriverManager.getConnection(strCon);
//创建一个可以滚动的只读的SQL语句对象
stmt = conn.createStatement();
} catch (SQLException ex) {
System.err.println("aq.executeQuery: " + ex.getMessage());
}
}/**
* 关闭数据库
*/
public void closeDB() {
try {
//关闭SQL语句对象
stmt.close();
//关闭数据库
conn.close();
} catch (SQLException ex) {
System.err.println("aq.executeQuery: " + ex.getMessage());
}
}/**
* 执行数据库SELECT查询
*
* @param sql 查询数据库的SELECT语句
*/
public ResultSet executeQuery(String sql) {
ResultSet rs = null; try {
rs = stmt.executeQuery(sql);
} catch(SQLException ex) {
//记录一个错误
System.err.println("aq.executeQuery: " + ex.getMessage());
}
return rs;
}/**
* 执行数据库INSERT, UPDATE, DELETE查询
*
* @param sql 查询数据库的SELECT语句
*/
public int executeUpdate(String sql) {
int ret = 0; try {
ret = stmt.executeUpdate(sql);
} catch(SQLException ex) {
System.err.println("aq.executeQuery: " + ex.getMessage());
} return ret;
}} //end of DBSQL
问题
javac: invalid flag: DBSQL.JAVAUsage: javac <options> <source files>where possible options include: -g Generate all debugging info -g:none Generate no debugging info -g:{lines,vars,source} Generate only some debugging info -nowarn Generate no warnings -verbose Output messages about what the compiler is doing -deprecation Output source locations where deprecated APIs are used -classpath <path> Specify where to find user class files -sourcepath <path> Specify where to find input source files -bootclasspath <path> Override location of bootstrap class files -extdirs <dirs> Override location of installed extensions -d <directory> Specify where to place generated class files -encoding <encoding> Specify character encoding used by source files -source <release> Provide source compatibility with specified release -target <release> Generate class files for specific VM version -help Print a synopsis of standard options
最下面是编译时的问题
import java.sql.*;public class DBSQL {
Connection conn;
Statement stmt;
String strCon;
/**
* 构造函数
*/
public DBSQL() {
conn = null;
stmt = null;
strCon = "jdbc:odbc:soft"; try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch (Exception ex) {
System.err.println("没有找到JDBC-ODBC数据库驱动器");
}
}/**
* 打开数据库,准备操作
*/
public void openDB() {
try {
//连接数据库
conn = DriverManager.getConnection(strCon);
//创建一个可以滚动的只读的SQL语句对象
stmt = conn.createStatement();
} catch (SQLException ex) {
System.err.println("aq.executeQuery: " + ex.getMessage());
}
}/**
* 关闭数据库
*/
public void closeDB() {
try {
//关闭SQL语句对象
stmt.close();
//关闭数据库
conn.close();
} catch (SQLException ex) {
System.err.println("aq.executeQuery: " + ex.getMessage());
}
}/**
* 执行数据库SELECT查询
*
* @param sql 查询数据库的SELECT语句
*/
public ResultSet executeQuery(String sql) {
ResultSet rs = null; try {
rs = stmt.executeQuery(sql);
} catch(SQLException ex) {
//记录一个错误
System.err.println("aq.executeQuery: " + ex.getMessage());
}
return rs;
}/**
* 执行数据库INSERT, UPDATE, DELETE查询
*
* @param sql 查询数据库的SELECT语句
*/
public int executeUpdate(String sql) {
int ret = 0; try {
ret = stmt.executeUpdate(sql);
} catch(SQLException ex) {
System.err.println("aq.executeQuery: " + ex.getMessage());
} return ret;
}} //end of DBSQL
问题
javac: invalid flag: DBSQL.JAVAUsage: javac <options> <source files>where possible options include: -g Generate all debugging info -g:none Generate no debugging info -g:{lines,vars,source} Generate only some debugging info -nowarn Generate no warnings -verbose Output messages about what the compiler is doing -deprecation Output source locations where deprecated APIs are used -classpath <path> Specify where to find user class files -sourcepath <path> Specify where to find input source files -bootclasspath <path> Override location of bootstrap class files -extdirs <dirs> Override location of installed extensions -d <directory> Specify where to place generated class files -encoding <encoding> Specify character encoding used by source files -source <release> Provide source compatibility with specified release -target <release> Generate class files for specific VM version -help Print a synopsis of standard options
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货