Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/367.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/89.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 从两个表中选择?_Java_Jquery_Sql - Fatal编程技术网

Java 从两个表中选择?

Java 从两个表中选择?,java,jquery,sql,Java,Jquery,Sql,使用Java数据库连接,我们可以声明一个查询,在该查询中,我们可以从两个表中进行选择 这是我的密码: public class Invoice { public static void main(String[] args) { int order_codej; java.sql.Date date1; java.sql.Date date2; int cust_codej; int quantity; int sum; doub

使用Java数据库连接,我们可以声明一个查询,在该查询中,我们可以从两个表中进行选择

这是我的密码:

public class Invoice {
    public static void main(String[] args) {
    int order_codej;
    java.sql.Date date1; 
    java.sql.Date date2;
    int cust_codej;
    int quantity;
    int sum;
    double pricej;
    String appellation;
    String name;
    String sname;
   Scanner input = new Scanner (System.in);
   System.out.print("Please insert order code: ");
   order_codej = input.nextInt();
    String url = "jdbc:odbc:part3";
    Connection dbcon ;
    Statement stmt;
    ResultSet rs;
    try {
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    } catch(java.lang.ClassNotFoundException e) {
        System.out.print("ClassNotFoundException: ");
        System.out.println(e.getMessage());}
    try {
        dbcon = DriverManager.getConnection(url,"x", "x");
        stmt = dbcon.createStatement();
        rs = stmt.executeQuery("SELECT order_code, sent_date, order_date, Orders.cust_code," +
                                "name, surname, price, appellation, product_sum, Consists.quantity" +
                                "FROM Orders, Customers, Products, Consists" +
                                "WHERE Orders.cust_code= Customers.cust_code AND" +
                                "Orders.order_code = Consists.order_code AND" +
                                "Consists.product_code = Products.product_code" +
                                "order_code =" + order_codej  );
        while (rs.next()) {
        order_codej = rs.getInt("order_code");
        date1 = rs.getDate("sent_date");
        date2 = rs.getDate("order_date");
        cust_codej = rs.getInt("cust_code");
        quantity = rs.getInt("quantity");
        sum = rs.getInt("product_sum");
        pricej = rs.getFloat("price");
        appellation = rs.getString("appellation");
        name = rs.getString("name");
        sname= rs.getString("surname");
        }
    rs.close();
    stmt.close();
    dbcon.close();
}
catch(SQLException e)
{
System.out.print("SQLException: ");
System.out.println(e.getMessage());
}
    }
}
在“.”附近输入正确的语法。这是编译后的信息,但它没有说我的问题出在哪里

看看:



可能与上面类似?

您的SQL查询代码中缺少空格: 示例“来自订单、客户、产品、组成”+ “来自……”
=>“来自订单、客户、产品、客户来自…”组与组之间没有空格

这也可能是架构设计不当的症状。如果你不能修改它(例如,在遗留数据库上工作),至少尝试创建一个视图。听说过连接吗?我对这一点很陌生,我还没有完全理解连接的概念。这就是我问题的答案吗?SQLException:[Microsoft][ODBC SQL Server驱动程序]描述符索引无效为什么会这样?
select 
  * 
from 
  table t1, 
  table t2
where 
  t1.id = t2.id;