In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "what are the interview questions for Javaweb". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "what are the interview questions for Javaweb"?
What are the basic steps for 61JI JDBC to access the database?
1, load driver
2. Obtain the connection object Connection through the DriverManager object
3. Get the session through the connection object
4. Add, delete, modify and query data through a session to encapsulate objects
5. Close the resource
62, talk about the difference between preparedStatement and Statement
1, efficiency: precompiled session than ordinary session object, the database system will not compile the same sql statement again
2, security: can effectively avoid sql injection attacks! Sql injection attack is to input some illegal special characters from the client, so that the server can still construct the sql statement correctly, so as to collect the information and data of the program and the server.
For example: "select * from t_user where userName ='" + userName + "'and password ='" + password + "'"
If the user name and password are entered as'1' or'1', the production sql statement is:
"the where part of the statement" select * from t_user where userName ='1' or'1 'has no effect on data filtering. "and password =' 1' or'1 has no effect on data filtering.
63, talk about the concept of transaction and the steps of dealing with transaction in JDBC programming.
A transaction is a series of operations performed as a single logical unit of work.
2. A logical unit of work must have four attributes, called atomicity, consistency, isolation, and persistence (ACID), in order to become a transaction
Transaction steps:
3again conn.setAutoComit (false); set the submission method to manual submission
4Query conn.commit () commit transaction
5. If an exception occurs, roll back conn.rollback ()
64, the principle of database connection pool. Why use connection pooling.
1. Database connection is a time-consuming operation, and connection pooling allows multiple operations to share a connection.
2. The basic idea of database connection pool is to establish a "buffer pool" for database connections. Put a certain number of connections in the buffer pool in advance, and when you need to establish a database connection, you only need to take one out of the "buffer pool" and put it back after use. We can prevent the system from making endless connections to the database by setting the maximum number of connections to the connection pool. More importantly, we can monitor the number and usage of database connections through the connection pool management mechanism, so as to provide a basis for system development, testing and performance adjustment.
3. Connection pooling is used to improve the management of database connection resources
What is the dirty reading of 65GI JDBC? Which database isolation level prevents dirty reads?
When we use a transaction, it is possible that a row of data has just been updated while another query reads the newly updated value. This leads to dirty reading, because the updated data has not been persisted, and the business that updates this line of data may be rolled back, so the data is invalid. The TRANSACTIONREADCOMMITTED,TRANSACTIONREPEATABLEREAD, and TRANSACTION_SERIALIZABLE isolation levels of the database prevent dirty reads.
66. What is phantom reading and which isolation level can prevent phantom reading?
Phantom reading means that a transaction executes a query multiple times but returns a different value. Suppose a transaction is querying data according to a condition, and then another transaction inserts a row of data that meets the query condition. The transaction then executes the query again, and the returned result set contains the new data that has just been inserted. This new line of data is called phantom row, and this phenomenon is called phantom reading.
Only the TRANSACTION_SERIALIZABLE isolation level can prevent phantom reading.
What is the DriverManager of 67 JGI JDBC used for?
JDBC's DriverManager is a factory class that we use to create database connections. When JDBC's Driver class is loaded, it registers itself into the DriverManager class
Then we will pass the database configuration information into the DriverManager.getConnection () method, and DriverManager will use the driver registered in it to obtain the database connection and return it to the calling program.
What is the difference between 68-minute executequery and executeUpdate?
The execute (String query) method of the String query statement is used to execute any SQL query and returns true if the result of the query is a ResultSet. If the result is not ResultSet, such as an insert or update query, it returns false. We can get the ResultSet through its getResultSet method, or get the updated number of records through the getUpdateCount () method.
The executeQuery (String query) interface of the statement is used to execute the select query and return ResultSet. Even if the ResultSet returned by the record cannot be queried, it will not be null. We usually use executeQuery to execute query statements, so that if an insert or update statement is passed in, it throws a java.util.SQLException with the error message "executeQuery method can not be used for update".
3 the executeUpdate (String query) method of insert statement is used to execute insert or update/delete (DML) statements, or nothing is returned. For DDL statements, the return value is of type int, if it is a DML statement, it is the number of updated entries, and if it is DDL, it returns 0.
You should use the execute () method only if you are not sure what statement it is, otherwise you should use the executeQuery or executeUpdate method.
What does the paging display of the results queried by 69SQL generally do?
Oracle:
Select * from
(select *, rownum as tempid from student) t
Where t.tempid between "+ pageSize* (pageNumber-1) +" and "+ pageSize*pageNumber
MySQL:
Select * from students limit "+ pageSize* (pageNumber-1) +", "+ pageSize
Sql server:
Select top "+ pageSize +" * from students where id not in +
(select top "+ pageSize * (pageNumber-1) + id from students order by id) +
"order by id
What is the ResultSet of 70Det JDBC?
A ResultSet is returned after querying the database, which is like a data table in the query result set.
The ResultSet object maintains a cursor that points to the current data row. At first, the cursor points to the first line. If the next () method cursor of ResultSet is called, it moves down one line, and if there is no more data, the next () method returns false. You can use it to traverse the dataset in a for loop.
The default ResultSet cannot be updated, and the cursor can only be moved down. That means you can only go through it from the first line to the last line. However, you can also create a ResultSet that can be rolled back or updated
When the Statement object that generated the ResultSet is about to close or re-execute or get the next ResultSet, the ResultSet object also closes automatically.
You can get the column data through the getter method of ResultSet, passing in the column name or the sequence number starting at 1.
At this point, I believe you have a deeper understanding of "what are the interview questions of Javaweb?" you might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.