import java.sql.*;public class Oracle_connection 
{
public Oracle_connection() 
{
}
public static void main(String[] args)
{
try
{
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
System.out.println("找到驱动!");
}
catch(java.lang.ClassNotFoundException e)
{
System.err.print(e.getMessage());
}
String url="jdbc:oracle:thin:@web:1521:oradb";
Connection conn=DriverManager.getConnection(url,"compiere","erecompi");
System.out.println("驱动连接成功!");
    String sql1="select a. created,a.documentno,b.name, c.name,d.qtyordered,e.name,e.upc,e.sku"
    +"from c_order a,c_bpartner  b,ad_user  c,c_orderline d,m_product"
 +" e  where  a.issotrx='N'  and a.c_bpartner_id"
 +"=b.c_bpartner_id and a.ad_user_id=c.ad_user_id and a.c_order_id=d.c_order_id "
+"and d.m_product_id=e.m_product_id "
+" order by a.documentno"; Statement stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery(sql1);
ResultSetMetaData rsmd=rs.getMetaData();
int count=rsmd.getColumnCount();
while(rs.next()){
for(int i=0;i<count;i++){
System.out.print(rs.getString(i+1)+"\t");
}System.out.println();
}

rs.close();
stmt.close();
conn.close();
}
catch(SQLException ex)
{
while(ex!=null)
{
System.out.println(ex.getSQLState());
}
}
}
}
一开始运行是我想要的结果,可我过一会再运行时就出现:
找到驱动
驱动连接成功
42000
42000
42000
一直都是42000,谁知道啊告诉我下立马给份不够再加急等!

解决方案 »

  1.   

    执行 String sql1="select a. created,a.documentno,b.name, c.name,d.qtyordered,e.name,e.upc,e.sku"
        +"from c_order a,c_bpartner  b,ad_user  c,c_orderline d,m_product"
     +" e  where  a.issotrx='N'  and a.c_bpartner_id"
     +"=b.c_bpartner_id and a.ad_user_id=c.ad_user_id and a.c_order_id=d.c_order_id "
    +"and d.m_product_id=e.m_product_id "
    +" order by a.documentno";
    看看
      

  2.   

    恩就是不能少""的问题可能我贴上去的时候没注意.原代码都有我用debug单步执行的时候
    我看它没有执行sql1不知道是怎么了高手们快出现啊.
      

  3.   

    你把sql语句System.out.print()打印出来看看