简体   繁体   English

尝试从 servlet 连接到 Oracle XE 时出现 ORA-01017 错误

[英]ORA-01017 error when attempting to connect to Oracle XE from servlet

I'm trying to write a servlet application for learning purposes that connects to an Oracle database, queries some data and then prints it to the browser.我正在尝试编写一个用于学习目的的 servlet 应用程序,该应用程序连接到 Oracle 数据库,查询一些数据,然后将其打印到浏览器。 Simple!简单的!

However, I'm experiencing an ORA-01017: invalid username/password when attempting to connect to a locally installed and running version of Oracle XE (19c).但是,我在尝试连接到本地安装和运行的 Oracle XE (19c) 版本时遇到了ORA-01017: invalid username/password For the sake of testing the connection, I'm connection with the system user.为了测试连接,我与系统用户连接。 Here's my code:这是我的代码:

// http://localhost:8080/demo/
public class DemoServ extends HttpServlet {

    public void doGet(HttpServletRequest req,HttpServletResponse res)
    throws ServletException,IOException {

        try{
            Class.forName("oracle.jdbc.driver.OracleDriver");
            Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1523:xe", "system", "SYSTEM");

            con.close(); 
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

The user that I'm using absolutely does exist, and I can connect using SQL Developer without issue.我使用的用户绝对存在,我可以使用 SQL Developer 进行连接而不会出现问题。

I would be willing to put this down to my own ignorance of Java, but if I run the following code independently of any servlet, I can connect and execute the sample query!我愿意把这归结为我自己对 Java 的无知,但是如果我独立于任何 servlet 运行以下代码,我可以连接并执行示例查询!

public class DataReader {

    public static void main (String [] args) {

        try {
            Class.forName("oracle.jdbc.driver.OracleDriver");

            Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1523:xe", "system", "SYSTEM");

            Statement statement = con.createStatement();
            ResultSet rs = statement.executeQuery("SELECT count(*) num FROM dual");

            if (rs.next()) {
                int i = rs.getInt("num"); // get first column returned
                System.out.println("number: " + i);
            }
            rs.close();
            statement.close();
            con.close();
        }
        catch (Exception e) {
            System.out.println(e);
        }
    }
}

I've been searching Google for solutions to this, but I have been unable to find a solution, so here I am.我一直在 Google 上搜索此问题的解决方案,但一直找不到解决方案,所以我来了。

I'm working on Windows 10, using Java 1.8 and Oracle 19c XE.我正在 Windows 10 上工作,使用 Java 1.8 和 Oracle 19c XE。

Any help would be great.任何帮助都会很棒。 Thanks谢谢

Okay, I finally go this to work, but I cannot explain why.好的,我终于开始工作了,但我无法解释原因。

Oracle 19c is case sensitive, which I knew. Oracle 19c 区分大小写,我知道。 I attempted to disable this, but as it's a depreciated feature, this seemed expeditious.我试图禁用它,但由于它是一个贬值的功能,这似乎很快。 I altered the password for the system user to be "system", and I can connect successfully.我把系统用户的密码改成“system”,就可以连接成功了。 "SYSTEM" as a password continues to fail. “SYSTEM”作为密码继续失败。

What strikes me as odd about this is that I'm sure that I tried to use the "system" (lowercase) password in the past.对此让我感到奇怪的是,我确信我过去曾尝试使用“系统”(小写)密码。 :( :(

Anyway, I probably was doing something daft, but at least I'm got over the hump.无论如何,我可能正在做一些愚蠢的事情,但至少我已经克服了困境。 Phew!呼!

Thank you to everyone!!谢谢大家!!

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

相关问题 Oracle JDBC:用户名/密码无效 (ora-01017) - Oracle JDBC : invalid username/password (ora-01017) 从TOMCAT迁移到IBM Websphere时,ORA-01017无效的用户名/密码 - ORA-01017 Invalid Username/Password when migrating from TOMCAT to IBM Websphere Oracle 11g r2 ORA-01017: 无效的用户名/密码; 通过 JDBC 驱动程序连接时登录被拒绝 - Oracle 11g r2 ORA-01017: invalid username/password; logon denied when connecting via JDBC driver ORA-01017:用户名/密码无效; 使用wss4j时登录被拒绝 - ORA-01017: invalid username/password; logon denied when using wss4j ORA-01017:无效的用户名/密码; 登录被拒绝 - ORA-01017: invalid username/password; logon denied TomEE ORA-01017服务器尝试通过OS用户进行身份验证 - TomEE ORA-01017 server tries to authenticate with OS user 如何修复'java.sql.SQLException:ORA-01017:无效的用户名/密码; 春季启动时登录被拒绝'错误 - How to fix 'java.sql.SQLException: ORA-01017: invalid username/password; logon denied' error in spring-boot java.sql.SQLException:ORA-01017:用户名/密码无效; 登录被拒绝 - java.sql.SQLException: ORA-01017: invalid username/password; logon denied 尝试从myeclipse中的servlet连接到mysql时访问被拒绝 - Access denied when attempting to connect to mysql from servlet in myeclipse 尝试调用servlet时遇到ERROR 404 - ERROR 404 encountered when attempting to call a servlet
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM