`

数据库及struts面试题

阅读更多
数据库部分
Q: What is SQL?

A: SQL stands for 'Structured Query Language'.
  结构化查询语言

Q: What is SELECT statement?

A: The SELECT statement lets you select a set of values from a table in a database. The values selected from the database table would depend on the various conditions that are specified in the SQL query.
select可以从数据库中的表格中选择一组数据。 

Q: How can you compare a part of the name rather than the entire name?

A: SELECT * FROM people WHERE empname LIKE '%ab%'
Would return a recordset with records consisting empname the sequence 'ab' in empname .
 

Q: What is the INSERT statement?

A: The INSERT statement lets you insert information into a database.
插入语句 用于向表格插入记录

Q: How do you delete a record from a database?

A: Use the DELETE statement to remove records or any particular column values from a database.
删除语句用于删除表格中某些记录

Q: How could I get distinct entries from a table?

A: The SELECT statement in conjunction with DISTINCT lets you select a set of distinct values from a table in a database. The values selected from the database table would of course depend on the various conditions that are specified in the SQL query. Example
SELECT DISTINCT empname FROM emptable 
 

Q: How to get the results of a Query sorted in any order?

A: You can sort the results and return the sorted results to your program by using ORDER BY keyword thus saving you the pain of carrying out the sorting yourself. The ORDER BY keyword is used for sorting.

SELECT empname, age, city FROM emptable ORDER BY empname
order by只能用于最后,对最后的查询结果进行排序,默认为升序,ASC,DEC

Q: How can I find the total number of records in a table?

A: You could use the COUNT keyword , example

SELECT COUNT(*) FROM emp WHERE age>40
注意聚集函数的使用,COUNT,SUM,MIN,MAX等

Q: What is GROUP BY?

A: The GROUP BY keywords have been added to SQL because aggregate functions (like SUM) return the aggregate of all column values every time they are called. Without the GROUP BY functionality, finding the sum for each individual group of column values was not possible. 


Q: What is the difference among "dropping a table", "truncating a table" and "deleting all records" from a table.

A: Dropping :  (Table structure  + Data are deleted), Invalidates the dependent objects ,Drops the indexes
Truncating:  (Data alone deleted), Performs an automatic commit, Faster than delete

Delete : (Data alone deleted), Doesn’t perform automatic commit


Q: What are the Large object types suported by Oracle?

A: Blob and Clob.

Q: Difference between a "where" clause and a "having" clause.

A: Having clause is used only with group functions whereas Where is not used with.
  TOP 

Q: What's the difference between a primary key and a unique key?

A: Both primary key and unique enforce uniqueness of the column on which they are defined. But by default primary key creates a clustered index on the column, where are unique creates a nonclustered index by default. Another major difference is that, primary key doesn't allow NULLs, but unique key allows one NULL only.


Q: What are cursors? Explain different types of cursors. What are the disadvantages of cursors? How can you avoid cursors?

A: Cursors allow row-by-row prcessing of the resultsets.

Types of cursors: Static, Dynamic, Forward-only, Keyset-driven. See books online for more information.

Disadvantages of cursors: Each time you fetch a row from the cursor, it results in a network roundtrip, where as a normal SELECT query makes only one rowundtrip, however large the resultset is. Cursors are also costly because they require more resources and temporary storage (results in more IO operations). Furthere, there are restrictions on the SELECT statements that can be used with some types of cursors.

Most of the times, set based operations can be used instead of cursors.


Q: What are triggers? How to invoke a trigger on demand?
触发器
A: Triggers are special kind of stored procedures that get executed automatically when an INSERT, UPDATE or DELETE operation takes place on a table.

Triggers can't be invoked on demand. They get triggered only when an associated action (INSERT, UPDATE, DELETE) happens on the table on which they are defined.

Triggers are generally used to implement business rules, auditing. Triggers can also be used to extend the referential integrity checks, but wherever possible, use constraints for this purpose, instead of triggers, as constraints are much faster.


Q: What is a join and explain different types of joins.

A: Joins are used in queries to explain how different tables are related. Joins also let you select data from a table depending upon data from another table.

Types of joins: INNER JOINs, OUTER JOINs, CROSS JOINs. OUTER JOINs are further classified as LEFT OUTER JOINS, RIGHT OUTER JOINS and FULL OUTER JOINS.
 

Q: What is a self join?

A: Self join is just like any other join, except that two instances of the same table will be joined in the query. 


struts部分

Q: What is Struts?

A: The core of the Struts framework is a flexible control layer based on standard technologies like Java Servlets, JavaBeans, ResourceBundles, and XML, as well as various Jakarta Commons packages. Struts encourages application architectures based on the Model 2 approach, a variation of the classic Model-View-Controller (MVC) design paradigm.

Struts provides its own Controller component and integrates with other technologies to provide the Model and the View. For the Model, Struts can interact with standard data access technologies, like JDBC and EJB, as well as most any third-party packages, like Hibernate, iBATIS, or Object Relational Bridge. For the View, Struts works well with JavaServer Pages, including JSTL and JSF, as well as Velocity Templates, XSLT, and other presentation systems.


The Struts framework provides the invisible underpinnings every professional web application needs to survive. Struts helps you create an extensible development environment for your application, based on published standards and proven design patterns.



Q: What is Jakarta Struts Framework?

A: Jakarta Struts is open source implementation of MVC (Model-View-Controller) pattern for the development of web based applications. Jakarta Struts is robust architecture and can be used for the development of application of any size. Struts framework makes it much easier to design scalable, reliable Web applications with Java.

 
Q: What is ActionServlet?

A: The class org.apache.struts.action.ActionServlet is the called the ActionServlet. In the the Jakarta Struts Framework this class plays the role of controller. All the requests to the server goes through the controller. Controller is responsible for handling all the requests.
  [ Received from Dhiraj Sharma]  TOP

Q: How you will make available any Message Resources Definitions file to the Struts Framework Environment?

A: T Message Resources Definitions file are simple .properties files and these files contains the messages that can be used in the struts project. Message Resources Definitions files can be added to the struts-config.xml file through <message-resources /> tag.
Example:

<message-resources parameter=\"MessageResources\" />.


  [ Received from Dhiraj Sharma]  TOP

Q: What is Action Class?

A: The Action Class is part of the Model and is a wrapper around the business logic. The purpose of Action Class is to translate the HttpServletRequest to the business logic. To use the Action, we need to Subclass and overwrite the execute() method. In the Action Class all the database/business processing are done. It is advisable to perform all the database related stuffs in the Action Class. The ActionServlet (commad) passes the parameterized class to Action Form using the execute() method. The return type of the execute method is ActionForward which is used by the Struts Framework to forward the request to the file as per the value of the returned ActionForward object.

  [ Received from Dhiraj Sharma]  TOP

Q: What is ActionForm?

A: An ActionForm is a JavaBean that extends org.apache.struts.action.ActionForm. ActionForm maintains the session state for web application and the ActionForm object is automatically populated on the server side with data entered from a form on the client side.

  [ Received from Dhiraj Sharma]  TOP

Q: What is Struts Validator Framework?

A: Struts Framework provides the functionality to validate the form data. It can be use to validate the data on the users browser as well as on the server side. Struts Framework emits the java scripts and it can be used validate the form data on the client browser. Server side validation of form can be accomplished by sub classing your From Bean with DynaValidatorForm class.
The Validator framework was developed by David Winterfeldt as third-party add-on to Struts. Now the Validator framework is a part of Jakarta Commons project and it can be used with or without Struts. The Validator framework comes integrated with the Struts Framework and can be used without doing any extra settings.



  [ Received from Dhiraj Sharma]  TOP

Q: Give the Details of XML files used in Validator Framework?

A: The Validator Framework uses two XML configuration files validator-rules.xml and validation.xml. The validator-rules.xml defines the standard validation routines, these are reusable and used in validation.xml. to define the form specific validations. The validation.xml defines the validations applied to a form bean.

  [ Received from Dhiraj Sharma]  TOP

Q: How you will display validation fail errors on jsp page?

A: Following tag displays all the errors:
<html:errors/>

  [ Received from Dhiraj Sharma]  TOP

Q: How you will enable front-end validation based on the xml in validation.xml?

A: The <html:javascript> tag to allow front-end validation based on the xml in validation.xml. For example the code: <html:javascript formName=\"logonForm\" dynamicJavascript=\"true\" staticJavascript=\"true\" /> generates the client side java script for the form \"logonForm\" as defined in the validation.xml file. The <html:javascript> when added in the jsp file generates the client site validation script.

  [ Received from Dhiraj Sharma]  TOP

Q: How to get data from the velocity page in a action class?

A: We can get the values in the action classes by using data.getParameter(\"variable name defined in the velocity page\");

分享到:
评论

相关推荐

    struts面试题详解

    在深入探讨Struts面试题之前,我们首先理解Struts1的基本架构和工作原理。 **1. Struts1框架的核心组件:** - **ActionServlet**:这是Struts1的核心控制器,它是一个实现了Servlet接口的类。当用户发起HTTP请求时...

    Struts2面试题及答案

    ### Struts2面试题及答案解析 #### 一、Struts2框架执行流程与核心组件 **题目背景:** 在Struts2框架中,FilterDispatcher是核心组件之一,它负责处理用户请求,并调用相应的Action进行业务逻辑处理。相较于...

    Java及数据库面试题 包含SSH,数据库和Java基础

    【Java及数据库面试题 包含SSH,数据库和Java基础】 1. SQL查询与数据库操作: 这一题目考察的是基本的SQL查询能力。在给出的示例中,我们看到如何从`Custom`表中选取特定列并重命名显示。`AS`关键字用于重命名列,...

    最全的IT公司面试题集 CHM版的

    数据库面试题,英语面试,外企面试,软件测试面试题,Python面试题,Oracle面试题,MySql面试题,Web开发面试题,Unix面试题,程序员面试,网络技术面试题,网络安全面试题,Linux面试题,Hibernate面试题,Spring面试题,SQL ...

    Struts面试题 Struts面试必备

    Struts 是一个基于MVC(Model-View-Controller)设计模式...尽管现代框架如Spring MVC和Play Framework等提供了更多功能和优化,但理解Struts的工作原理和优缺点,对于Java程序员尤其是面试者来说,仍然是十分重要的。

    2014 java servet jdbc struts struts2面试题

    【Struts2面试题】 1. **Struts2架构**:基于MVC模式,了解Action、Result、Interceptor等核心组件。 2. **Struts2拦截器**:自定义拦截器,理解默认拦截器栈及其作用。 3. **Struts2配置**:struts.xml文件,...

    尚硅谷JAVA数据库等面试题集

    【标题】"尚硅谷JAVA数据库等面试题集"所涵盖的知识点主要集中在Java、SSH(Struts+Spring+Hibernate)框架以及SQL这三大领域,这些都是IT行业尤其是软件开发中的核心技能。面试题集通常会包括各种技术问题,旨在...

    最新Java面试题视频网盘,Java面试题84集、java面试专属及面试必问课程

    面试题包含了不同技术层面的面试问题,同时也能对一些没有面试开发经验的小白给予不可估量的包装, 让你的薪水绝对翻倍, 本人亲试有效.Java面试题84集、java面试专属及面试必问课程,所有的面试题有视屏讲解, 解答方案....

    程序员面试手册-超级全的程序员面试题-CHM版

    数据库面试题,英语面试,外企面试,软件测试面试题,Python面试题,Oracle面试题,MySql面试题,Web开发面试题,Unix面试题,程序员面试,网络技术面试题,网络安全面试题,Linux面试题,Hibernate面试题,Spring面试题,SQL ...

    spring struts hibernate面试题

    【Spring Struts Hibernate面试题详解】 在面试中,关于SSH(Spring、Struts、Hibernate)的知识点通常是Java Web开发人员必须掌握的核心内容。下面将详细解释这些技术的关键特性和应用场景。 1. **MVC设计模式** ...

    最新Struts和Hibernate和Spring经典面试题

    Struts、Hibernate 和 Spring 经典面试题 以下是对 Struts、Hibernate 和 Spring 的经典面试题的总结,涵盖了这些框架的工作机制、优点、缓存机制、查询方式、优化方法等知识点。 Hibernate 1. Hibernate 工作...

    面试知识点总结--struts面试题大全.pdf

    在面试中,理解Struts的核心概念、优缺点以及它如何实现MVC模式至关重要。 1. **Struts的优点**: - 开源:允许开发者深入理解其工作原理。 - 行业标准:在Web开发中广泛采用,丰富的学习资源。 - Taglib(标签...

    2021年最新java面试题--视频讲解(内部培训84个知识点超详细).rar

    Java面试题48.struts2的执行流程或者struts2的原理 Java面试题49.Struts2的拦截器是什么 Java面试题50.Spring MVC的执行流程 Java面试题51.SpringMVC和Struts2的不同 Java面试题52.简单介绍一下Spring或者Spring的两...

    Struts+Hibernate+Spring面试题合集及答案常见题目经典精选汇总大全.docx

    这些面试题涵盖了Hibernate、Struts和Spring的主要概念、工作原理和最佳实践,深入理解和掌握这些知识点对于Java开发者来说至关重要。在实际面试中,除了基础理论知识,面试官还会关注开发者在项目中如何应用这些...

    java程序员面试题——863面试集

    - **SSH (Struts + Spring + Hibernate) 框架面试题**: 综合考察三个框架之间的集成和协作。 #### 三、数据库和框架配置 - **数据库在 JDBC 中的连接方法**: JDBC 连接池、驱动加载等。 - **Struts 和 Hibernate ...

    struts hibernate spring 面试题大全

    - **面试题示例:**解释Struts的工作流程;什么是ActionForm?如何处理表单验证? 2. **Hibernate框架** Hibernate是一个对象关系映射(ORM)框架,它允许开发者用Java对象来操作数据库,简化了数据库操作的复杂...

    struts2面试题

    以下是一些关于Struts2面试题的详细知识点: 1. **Struts2框架概述** - Struts2是Apache软件基金会下的一个开源项目,它是Struts1的升级版,提供了更优秀的性能和更灵活的架构。 - 它基于拦截器的MVC框架,使得...

    SSH(struts+spring+hibernate)面试题总结

    以下是对SSH面试题中涉及的一些核心知识点的详细解释: 1. **Hibernate 工作原理** Hibernate 的工作流程主要包括: - 读取`hibernate.cfg.xml`配置文件,创建`Configuration`实例,加载类映射信息。 - `...

    Java+数据库面试题.zip

    以下是对"Java+数据库面试题.zip"中可能包含的重要知识点的详细说明: 1. **Java基础**: - **面向对象编程**:包括类、对象、封装、继承、多态等核心概念。 - **异常处理**:理解如何使用try-catch-finally语句...

Global site tag (gtag.js) - Google Analytics