Java Internet face test questions have XX network (Internet finance C-round enterprise) face examination Questions __java

Source: Internet
Author: User
Tags connection pooling manage connection mysql in cpu usage

This interview question is my summary after the interview, I put all can think of all write, if there is anything wrong, please correct me

XX Network interview problem

1, Oracle and MySQL pagination are how to page.

2, Oracle rowID and rownum what is the difference;

3, Oracle or MySQL data volume than the time when the paging will be relatively fast, that is, how to use rowid keywords to quickly pagination;

4, the MySQL data volume is very large (millions of tens of millions of) when how to page query;

5, Oracle and MySQL paging use the order by side in which location;

(6) Index: The difference between a Single-column index and a federated index; multiple fields (A, B, C) Three Word fields when federated index, if only BC, will not go this index, database parsing SQL order, SQL parser, turn into execution plan

7, the database SQL parsing sequence, SQL parser, execution plan;

8, database connection pool related issues;

9, thread pool;

10, distributed framework: Dubbo;

11, see more source code;

12, Java synchronization synchronized problem;

13, set Class: Collection and set list of a subset of ArrayList and LinkedList differences; How to turn these two lists into thread safe list

14, Linux Common instructions: Top, kill-9: Why to add-9.

15, Linux to a user's number of threads constraints;

16, Oracle aggregate query function;

17. Where the single case mode is used;

18, the responsibility chain mode is how to achieve, the strategic model and responsibility chain model of the difference;

19, has not written a filter;

20, springmvc commonly used annotations; Ulimit, service, Controler, Responsebody, Transaction

21, the timing of the task failed to rerun how to run, text messages and emails because of network reasons failed, there are 100 people, only 30 people, the system after the restart how to achieve resend the remaining 70 people method;

22, SPRINGMVC transaction on which layer (DAO layer, service layer, controller layer);

23. (Transaction) The annotation of the business;

24, Redis Cache;

25, MQ cache system;

The interviewer suggested that the design pattern should be written with little or no problem, but the Java basics should be noted;

Answer

1, for MySQL database, we can use the limit statement for pagination, for Oracle database, we can use rownum way to pagination;

L MySQL limit m,n statement;

In the two parameters after limit, the parameter m is the starting table, starting at 0, and the parameter n is the number of records returned. We need to page the top of the two values can be;

L oracel database rownum ';

In an Oracle database, paging is not as simple as MySQL, and it needs to be implemented on a rownum basis. The rownum represents the line number of a record that is loaded into memory and then fetched. He is to get each row before giving it line number, so want to top rownum of the interval to get the paging data in a layer of query statements can not be done, to pagination and to do a query.

Select * FROM

(

Selecta.*, A.rownum RN from a

(

(Select * from user) a where a.rownum<20

) Where rn>10;

)

The most inner query select * Fromuser represents the original query statement without paging.

ROWNUM<20 and RN 10 controls the scope of each page of the paging query, which is more efficient in most cases, given this share query condition. The purpose of paging is to control the size of the output result set and return the result set as quickly as possible. In the query above, this consideration is mainly reflected in where A.rownum <20, and there is a query method as follows:

Select * FROM

(

Select A.*,rownum RN from

select* from User A

where RN between 20

)

In most cases the first method of high efficiency, high efficiency is related to the SQL parsing sequence, the students interested in their own Baidu

2. What's the difference between rowed and rownum?

RowNum and rowID are virtual columns , but their meanings are completely different. rowID is the physical address that locates the physical storage location of the specific data in Oracle, while RowNum is the sort of SQL output result. In layman's terms: ROWID is immutable, and rownum is changeable, especially when using order by;

Rowed: The location that is used to locate a piece of data in a datasheet is unique and unchanging.

RowNum: To query the location of a record in the entire result set, the same record query conditions different corresponding to the glory of the different, and ROWID will not change.

3, Oracle and MySQL data volume is large, how to optimize the SQL, so that it in the paging when the query faster;

4, Oracle and MySQL in the use of pagination, by which place.

Oracle uses the by-by when paging, placed inside two layers of nesting, in two WHERE clauses: where rownum<30 and whererownum>10.

5, the difference between the single row index and the joint index, how to use the joint index;

Single-column Index: The index query can be used whenever the index column appears in the condition (in the WHERE clause), regardless of the location;

Federated Index: 1, the first column of the Union index appears in the criteria query, or all, it can take advantage of the Federated index (which has to do with the SQL parsing order); 2), if the conditions are connected together, both before and after the union index is used, 3, the query condition does not appear the first column of the Union Index, The second or third column of the Federated Index appears, neither the federated index is used for querying.

When do I need to build an index? In general, the columns that appear in the where and jion need to be indexed, but not exactly, because MySQL is just <,<=,=,>,>=,between, in, And at some point the science uses indexes; MySQL does not use indexes when querying with wildcard characters% and _.

The disadvantage of indexing: Although the index greatly improves the speed of the query, colleagues will reduce the speed of the update table, such as the table for INSERT, UPDATE, delete; because when you update the table, MySQL will not only save the data, but also save the index file.

If you have a large amount of data and you use an index at the same time, if you need to add a large amount of data, you can delete the index in the wee hours, then add the data, add the data, and then talk about the federated Index Plus.

6, SQL parsing sequence, SQL parser-this part of their own Baidu bar

7. Database Connection pool:

The database connection pool is responsible for allocating, managing, and releasing database connections, allowing applications to reuse an existing database connection instead of building a database that frees up idle time beyond the maximum idle time to avoid missing database connections caused by not releasing database connection two. This technology can significantly improve the performance of database operation;

Principle: The basic idea of the connection pool when the system initializes, the database connection is stored as an object in memory, and when the user needs to access the database, not a new connection is made, but an established idle connection object is removed from the connection pool. Once used, the user does not close the connection, but instead puts the connection back into the connection pool, which is used for the next request access. And the connection of the establishment, disconnect are connected to the pool itself management. Colleagues can also control the connection pool initial connection number, the connection's upper and lower limits and each connection maximum usage, the maximum idle time and so on by setting the connection pool parameters;

Open source database connection pool in Java there are several: DBCP, Proxool, c3p0

C3P0 compared with small resources, the efficiency is low;

DBCP there are bugs;

Proxool is good, and provides real-time monitoring of connection pool status functions to facilitate the discovery of connection pool leaks.

Relationship between connection pooling, data source, and Jndi:

Connection pooling:

A connection pool is provided by a container (such as Tomcat) to manage connection objects in a connection pool;

The connection pool automatically assigns the connection object and recycles the idle connection;

The connection objects in the connection pool are created by the data source (DataSource).

Connection pooling (Connection pool) for managing connection (Connection) objects

Data Source:

A data source (DataSource) is used to connect to a database, create a connection (connection) object;

The Java.sql.DataSource interface is responsible for establishing a connection to the database, with Tomcat provided to keep the connection in the connection pool.

Jdni (Java naming and directory Interface,java naming and directory interfaces):

Using Jndi in your program to get the data source, the connection object created through the data source is uniformly put into the connection pool for management

8, thread pool problem more, also more complex, here do not explain, specifically please own Baidu: http://www.importnew.com/12773.html

9, distributed framework dubbo--own Baidu Bar, I have no use ...

10, javasynchronize problem also own Baidu Bar, online are the answer;

11, the Collection class: ArrayList and LinkedList difference:

ArrayList query is faster, the interior is used to implement the array, the array has subscript, so the query speed faster, increase and modify the slower, linkedlist in the increase and modify the faster, the query is slow, linkedlist internal implementation for chain structure, the elements of the storage of the end connected, Find the previous one can directly find the latter element, so in addition or modification can be directly modified to point to the next element of the address, but the query is slow, to traverse the entire list for query;

Where ArrayList is thread-unsafe, LinkedList is thread-safe. How to turn two list into a thread-safe list:

List<string> list =collections.synchornizedlist (new arraylist<string> ());

List<string> list =collections.synchornizedlist (new linkedlist<string> ());

For more details, please see: http://blog.csdn.net/hp_yangpeng/article/details/78510991

12, the server maintenance commonly used instructions:

Top command Details: This command is often used to monitor Linux system conditions, such as CPU, memory usage


First line:

1:08:45: System Current time;

The days,3:05-system has been running for 10 days, 3 hours and 05 minutes (no reboots during this period);

Load average: The following three parameters need to be calculated, after calculation can be judged whether overload operation;

Second line:

tasks:135 Total, the system now has 135 processes, one of which is running, 134 are sleeping, and 0 zombie processes (zombie: zombie processes);

Third line: The state of the CPU (total four CPUs)

0.3%us-% of CPU consumed by user space;

0.0%sy– internal medical space occupied CPU percentage;

0.0%ni-the percentage of CPU consumed by the process that has changed the priority

0.0%wa-io waiting to consume CPU percent

0.0% hi– Hard Interrupt (Hardware IRQ)% of CPU usage

0.0% si-Soft medium soft (software interrupts) The percentage of CPU occupied;

Line four: Memory status

3908060k total-Total Physical memory (4g);

3660048k used– Total Memory in use (3.6G)

148012k free-Total free memory (148M)

Amount of memory cached by 359760 buffers– (359M)

Kill-9 Kill Process:-9 is to force stop process, sometimes only use kill, process cannot kill;

See:http://blog.csdn.net/hp_yangpeng/article/details/78511051

13. Linux constraints on the number of threads of a user

View the maximum number of threads supported by the system, generally large, equivalent to the theoretical value;

Cat/proc/sys/kernel/pid_max----------32768

Cat/proc/sys/kernel/threads–max 4132217

Max_user_process #系统限制某哟用户下最多可以运行多少线程或进程, using the command: Ulimit–u

Ulimit–u-----------1024

Note: Modify the value of the max_user_process, only the knee/etc/security/limits.conf can be, but this parameter needs to be modified/etc/security/limits.d/90-nproc.conf

14, Oracle Aggregate query function: Commonly used aggregate functions are: Sum, AVG, MIN, Max, Count, and other aggregate functions, please own Baidu Bar.

15. Java Design pattern

Simple mode: Mainly lazy mode, a hungry man mode,

Specifically implemented as follows:

1, lazy mode, thread safety:

public class singleon{

Privatestatic Singleton instance;

Priate Singleton () {}

public static synchronized Singletongetinstance () {

If (instance==null) {

Instance= new Singleton ();

}

return instance;

}

}

2, a hungry man mode, thread safety;

public class Singleton {

Privatestatic Singleton instance = new Singleton ();

Private Singleton () {}

public static Singleton getinstance () {

return instance

}

}

The responsibility chain mode content is more, suggest to watch video to study on the net;

16, Redis and MQ cache problem more, suggest oneself slowly study (I will not)

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.