繁体   English   中英

使用 Eclipse 连接到数据库 Oracle 11G () 的问题:

[英]probleme of connection to Database Oracle 11G () withe Eclipse :

package oracleDBconnexion;

import java.sql.*;
public class jdbcConnexion {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        try {
           Class.forName("oracle.jdbc.driver.OracleDriver");
           Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:iliassalilou","system","system");
           Statement st =con.createStatement();
           String  sql="select from DEPT *";
           ResultSet rs=st.executeQuery(sql);
           while (rs.next()) {
             System.out.println(rs.getInt(1)+" "+ rs.getString(2)+" "+rs.getInt(3)+" "+rs.getString(4)+" "+rs.getString(5));  
           }
           con.close();
        }
        catch(Exception e) {
            System.out.println(e);
            }
        }

}

在控制台中:

java.sql.SQLSyntaxErrorException:ORA-00936:缺少表达式

您的 SQL 语法错误。 *通配符应在 select 列表中:

String sql = "select * from DEPT";
// Here -------------^

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM