[英]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.