在JDBC瘦驱动程序中获取异常

时间:2014-06-27 06:14:50

标签: java jdbc oracle11g

我尝试使用Java运行查询,下面提到的是我的程序

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.naming.spi.DirStateFactory.Result;
public class Oracleconn {
    public static void main(String[] args) {
                try {
            Class.forName("oracle.jdbc.driver.OracleDriver");

            Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:yglobal","user","user");

            Statement stmt = con.createStatement();

            ResultSet rs = stmt.executeQuery("select empid from empmaster");
            while(rs.next())
            System.out.println(rs.getint(1));
            con.close();            
        } catch (Exception e) {
            e.printStackTrace();
        }}
}

但是当我试图运行这个程序时,我得到了异常

java.sql.SQLException: ORA-01756: quoted string not properly terminated
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:207)
at oracle.jdbc.driver.T4CStatement.executeForDescribe(T4CStatement.java:790)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1038)
at oracle.jdbc.driver.T4CStatement.executeMaybeDescribe(T4CStatement.java:830)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1133)
at oracle.jdbc.driver.OracleStatement.executeQuery(OracleStatement.java:1273)
at jdbc.Oracleconn.main(Oracleconn.java:28)

0 个答案:

没有答案