首页 \ 问答 \ java中的接口和继承(interface and inheritance in java)

java中的接口和继承(interface and inheritance in java)

我有一个关于如何将接口与继承关联的问题,例如:

如果A类实现了接口X,那么A类也是B类和C类的超类,我的问题是,这是否意味着B类和C类都会自动实现接口X?


I have a question of how to relate interface to inheritance, for example:

if class A implements interface X, also class A is the superclass of class B and class C, my question is , does it mean both class B and class c will automatically implement interface X as well?


原文:https://stackoverflow.com/questions/19681884
更新时间:2022-01-28 13:01

最满意答案

您会错过颜色字段和where子句中的单引号。

"UPDATE file1  SET  name='" + dt.getName()+ "',age='" + dt.getAge()+ "',color='"+dt.getColor()+ "'"
+ " WHERE name='" + dt.getName() + "'";

此外,您应该使用参数化语句,原因有很多:防止SQL注入,提高可读性,以及DBMS通常更有效地执行查询。

"UPDATE file1  SET  name=?,age=?,color=? WHERE NAME =?";

pst.setString(1, dt.getName());
pst.setInt(2, dt.getAge());
(etc...)

You miss the single quotes for the color field, and in the where clause.

"UPDATE file1  SET  name='" + dt.getName()+ "',age='" + dt.getAge()+ "',color='"+dt.getColor()+ "'"
+ " WHERE name='" + dt.getName() + "'";

Also, you should use paramaterized statements, for a lot of reasons: protection against sql injection, improved readability and often more efficient query execution by your DBMS.

"UPDATE file1  SET  name=?,age=?,color=? WHERE NAME =?";

pst.setString(1, dt.getName());
pst.setInt(2, dt.getAge());
(etc...)

相关问答

更多
  • 始终逃避所有用户输入。 您的更新查询应该看起来像 $sql1 = "UPDATE $tbl_name SET available='".mysql_real_escape_string($_POST['available'][$i])."', rent='".mysql_real_escape_string($_POST['rent'][$i])."', corp_ready='".mysql_real_escape_string($_POST['corp_ready'][$i])."', do ...
  • 您会错过颜色字段和where子句中的单引号。 "UPDATE file1 SET name='" + dt.getName()+ "',age='" + dt.getAge()+ "',color='"+dt.getColor()+ "'" + " WHERE name='" + dt.getName() + "'"; 此外,您应该使用参数化语句,原因有很多:防止SQL注入,提高可读性,以及DBMS通常更有效地执行查询。 "UPDATE file1 SET name=?,age=?,color=? ...
  • 绝对不要把“一切都放在一张桌子上”。 你可能会得到“很多表”,但这听起来很糟糕 - 基本上,你应该根据逻辑用法来分割你的数据。 例如,如果您在用户表中保留帖子 - 这将如何工作? 当他们发表一篇新文章时会发生什么 - 你会添加另一个领域吗? (坏) - 或者将其他项目添加到一个字段中并用字符(坏)分隔...等等。 做到这一点的唯一真正方法是另一张桌子。 您绝对不应该将帖子与用户保持在同一张表中 。 就“档案数据”(或任何你想称之为的)而言,我喜欢将它分开 - 有些人喜欢将它保留在用户表中 - 这是偏好问题。 ...
  • 你错过了UPDATE语句中$ _POST ['id']之后的结束单引号,并且你还有一个在WHERE条件之前不需要的逗号。 尝试: $upd= "UPDATE `employees` SET `emp_no`='".$_POST['name']."' WHERE `id`='".$_POST['id']."'"; You are missing the closing single quote after the $_POST['id'] in the UPDATE statement and you al ...
  • 您可以使用带有LEFT JOIN的UPDATE: UPDATE MY_DATABASE_TABLE t1 LEFT JOIN MY_DATABASE_TABLE t2 ON t1.ip_address=t2.ip_address AND t1.date
  • MySQL无法读取变量won因此您必须将其作为参数传递给.execute() : won = 1 sql = "UPDATE loot SET win = %s WHERE id = %s" cursor.execute(sql,(won,1)) db.commit() 请注意,您必须将某种容器作为.execute()的第二个参数。 在这种情况下,它是一个元组。 MySQL isn't able to read the variable won so you must pass it in as an a ...
  • prc.user: id_user:45 | name_user:测试| login_user:test | pwd_user:测试 prc_test.user id_user:45 | name_user:测试| login_user:test | pwd_user:测试 样本查询: UPDATE prc.user, prc_test.user SET prc_test.user.pwd_user = prc.user.pwd_user WHERE prc_test.user.n ...
  • 正确的MySQL语法是: update matrimonyrequests mr INNER JOIN subhamastu.matrimony_response smr ON mr.reqid=smr.matrimony_response_id set reqprofile_id = subhamastu.response_to ; 您的语法看起来更像SQL Server。 The correct MySQL syntax is: update matrimonyr ...
  • 问题是字段名称周围的引号。 MySQL不允许使用单引号字段名称。 它们必须是裸(A1)或反引号('A1`),因此您的查询应该重写为: INSERT INTO table1 (A1, A2, A3, A4, A5, A6, A7, A8) VALUES ('test1', 'test2', 'test3', 'test4', etc.....); The problem is the quotes around the field names. MySQL doesn't allow single-quot ...
  • 你在这里犯了一个很大的错误,为什么你在foreach循环中使用$result ? FRom哪里有$result ? $result是sql查询的资源。 尝试这个: if(isset($_POST['update'])){ $total = count($_POST['rank']); $user_id_arr = $_POST['user_id']; $rank_arr = $_POST['rank']; for($i = 0; $i < $total; $i++){ ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。