简体   繁体   English

ORA-04054:数据库链接GMAIL.COM不存在

[英]ORA-04054: database link GMAIL.COM does not exist

I need help with my college's project(Java web with hibernate and oracle database), this has to edit the users already added previously which have: Mail pk pass typeuser.iduser FK. 我需要大学项目的帮助(带有休眠和Oracle数据库的Java Web),这需要编辑以前添加的用户,这些用户有:Mail pk pass typeuser.iduser FK。

add and remove it works but doesnt edit, the error is : javax.servlet.ServletException: java.sql.SQLSyntaxErrorException: ORA-04054: database link GMAIL.COM does not exist 添加和删​​除它可以正常工作,但无法编辑,错误是:javax.servlet.ServletException:java.sql.SQLSyntaxErrorException:ORA-04054:数据库链接GMAIL.COM不存在

i already tried with using prepared statement but i think i did it wrong 我已经尝试使用准备好的语句,但是我认为我做错了

the mail does not need to be edited. 邮件不需要编辑。 only the type of user and password needs it but at the moment of pressing the edit button it shows me the error gmail.com does not exist 只有用户和密码的类型需要它,但是在按下编辑按钮时,它向我显示错误gmail.com不存在

<%
            //CONECTANOD A LA BASE DE DATOS:

            Class.forName("oracle.jdbc.OracleDriver").newInstance();
            Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE", "C##PORTA", "oracle");
            String id = request.getParameter("correo");
            PreparedStatement  stm = con.prepareStatement(id);
            String Query = "select * from usuario where correo=" + id;
            PreparedStatement ps;
            ResultSet rs = stm.executeQuery(Query);
            while (rs.next()) {
        %>``` 



OldProgrammer has shown you the correct way to do this. OldProgrammer 您展示了执行此操作的正确方法。 If you use a PreparedStatement (correctly) it will deal with quoting correctly, and also protect against SQL injection attacks. 如果正确使用PreparedStatement,它将正确处理引用,并防止SQL注入攻击。

The reason you got the obscure error message was that your SQL statement most likely looks something like this after you concatenated it: 收到晦涩的错误消息的原因是,连接后,您的SQL语句很可能看起来像这样:

 select * from usuario where correo=someone@gmail.com

Since the email address is not quoted, the SQL parser doesn't recognize that as a string literal. 由于未引用电子邮件地址,因此SQL解析器无法将其识别为字符串文字。 Instead, it is treating it as a "db link" as described in CREATE DATABASE LINK . 而是按CREATE DATABASE LINK中的描述将其视为“数据库链接”。

After you have created a database link, you can use it in SQL statements to refer to tables and views on the other database by appending @dblink to the table or view name. 创建数据库链接后,可以通过在表或视图名称后附加@dblink,在SQL语句中使用它来引用其他数据库的表和视图。

And that fails because no such database link with the name "gmail.com" has been created. 但这失败了,因为尚未创建名称为“ gmail.com”的此类数据库链接。

You are not calling the correct methods with the correct parameters. 您没有使用正确的参数调用正确的方法。 Should be something like: 应该是这样的:

        String id = request.getParameter("correo");
        String query = "select * from usuario where correo= ?";
        PreparedStatement  stm = con.prepareStatement(query);
        stm.setString(1, id );
        ResultSet rs = stm.executeQuery();

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

相关问题 错误“ java.sql.SQLException:ORA-04054” JDBC-ORACLE - Error “java.sql.SQLException: ORA-04054” JDBC-ORACLE Android创建自定义键“ @ hotmail.com”,“ @ gmail.com” - Android create custom key “@hotmail.com”,“@gmail.com” 如何在 Java 中连接用于邮件访问的证书 gmail.com - How to connect a certificate for mail access gmail.com in Java 浏览器中的证书验证(具体情况:https://gmail.com) - Certificate validation in browsers (specific case: https://gmail.com) 如何创建正则表达式以验证仅包含gmail.com的字符串? - How to create regex to validate string which contains only gmail.com? ORA-02289序列不存在,但是数据库中存在序列 - ORA-02289: sequence does not exist, however sequence is aleady exist in database 错误:包com.firebase.ui.database不存在 - error: package com.firebase.ui.database does not exist 我们可以使用Web驱动程序来测试https:// sites吗? 我正在尝试在gmail.com上工作,但它不起作用 - Can we use Web driver to test https:// sites? I am trying to work on gmail.com and it doesn't work java.sql.SQLException:ORA-00942:表或视图不存在,每三分之一命中数据库 - java.sql.SQLException: ORA-00942: table or view does not exist, getting in every third hit to database ORA-00942:表或视图不存在 - ORA-00942: Table or view does not exist
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM