JDBC Frequently asked Questions

Source: Internet
Author: User

  1. is JDBC not a pure network connection database?

    A: The network connection, the bridge is no longer used


  2. Class.forName () is not specifically used to drive the load?

    A: Specifically used to load classes


  3. On which interface is the transaction control controlled?

    Answer: Connection interface


  4. Is the isolation of the transaction set in that interface?

    Answer: Connection interface


  5. What is the database connection pool optimized for?

    Answer: Optimizations on database connection objects


  6. The advantages and disadvantages between DBCP and c3p0 simply say?

    A: C3p0 not so resource-intensive, dbcp to consume some resources, and c3p0 faster than DBCP


  7. Does preventing SQL statement injection use that interface to execute SQL statements can prevent injection problems?

    Answer: PreparedStatement interface


  8. Can a stored procedure call return a recordset?

    Answer: You can


  9. I have a stored procedure getName () inside two parameters an int one takes out the parameter, ask me how to write the called string in Java

    Answer: {call GetName (?,?)}


  10. If I want to get the table structure of the query, can I get a table structure object in that object?

    Answer: ResultSet object


  11. Can I get the data backwards in the resultset?

    A: Yes, you can use the ResultSet object to call the Afterlast method first, call the previous method before the value


  12. Can we connect MySQL to Oracle or DB2 in one program?

    A: Yes, you can control the connection object of the respective database.


  13. How do I set the manual commit Transaction mode? The method? What parameters

    Answer: Use the Connection object to call the Autocommit method to pass the false parameter


  14. I have set up a manual commit transaction, and finally did not call commit or rollback will report an error?

    Answer: No, the default is to connect to localhost


  15. You've used a method that has had this effect before, and now it's not working? Why does such a thing happen?

    A: Java only declares the interface, the implementation method is written by the various database companies, if the implementation method is modified, then the effect will naturally change


  16. We modified the data state, but the other side of the transaction is not visible, because I do not have a transaction to commit, how can I let other things see the modified data not submitted?

    A: Set the transaction isolation level of the database to: READ UNCOMMITTED (UNCOMMITTED)


  17. What if I use a query to deploy his lock?

    Answer: Add a for update at the end of the SELECT statement


  18. What locks can be added multiple times in a single record?

    Answer: Shared lock


  19. Do I need to wait for the other person to release the lock when I modify the shared lock lock record?

    Answer: No, you need to release the lock to modify


  20. Whether an exclusive lock lock data can be locked by a shared lock

    Answer: No, the exclusive lock is very strict and cannot be locked by another lock.


  21. Lock table and lock line in MySQL, that consumes some resources?

    A: The lock line consumes some resources


  22. SQL batch can be executed on those interfaces?

    Answer: statement and PreparedStatement interface


  23. Execute SQL When do we choose statement or PreparedStatement?

    A: When the SQL statement is written by the developer, make sure that SQL injection does not occur, you can use statement, if it is a user input through text, the use of SQL injection problems may occur preparedstatement


  24. Could we use statement to execute DDL statements?

    A: Yes, you can execute any SQL statement using the Execute method


  25. MySQL database connection string If the database name is not filled in, will be error

    Answer: No error, after the SQL statement written in this format can select * from Jdbc.student


  26. Database connection pool, what method can be used to put connection back in the pool

    Answer: The Close method


  27. Does the connection pool have a shutdown method? Close Connection Pool

    Answer: Yes, the same is the Close method


  28. Can a connection query for SQL connect multiple tables?

    Answer: You can


  29. Connect query criteria use on later can I also use where?

    Answer: You can


  30. The amount of data in a table is very large, what can you do to optimize it?

    A: Table partitioning, multiple table storage, setting primary key, index, using MyISAM engine


  31. How to solve the large amount of data query method?
    Answer: Use the Limit paging query


  32. Why is it best to search by primary key?

    Answer: Because the primary key has an optimized query, and the primary key is unique


  33. Association relationship, is to let the database maintenance relationship, or our program maintenance, that way good?

    A: Database maintenance, self-maintenance needs to open a lot of business, more trouble


  34. Do we have a larger file to store in the database? Why is it suitable for storing large files?

    Answer: Can be stored, but the database is not suitable for storing files, mainly for the following reasons:

1. Read/write to the database is never as fast as File system processing
2. Database backup has become huge and time-consuming
3. Access to files needs to traverse your application layer and database layer


35. We operate using a connection object what's wrong with it?

A: A connection object is not busy at all, and now the Web site concurrency is larger will lead to data chaos, asynchronous problem, now is the era of multithreading


36. Connect to the database, what is the driving load?

Answer: Register driver, load static member


37. Is there any way to know what the AutoNumber ID is after you insert?

Answer: Use the Select last_insert_id () statement


38.MySQL Improve query efficiency we use that engine.

Answer: MyISAM engine, but this engine does not support transactions


39.Connection connected to the database, what protocol is used?

Answer: TCP/IP protocol


What method does 40.DBunit use to conduct database testing?

A: Avoid destroying data by using XML files to back up and restore database data

This article is from the "zero" blog, make sure to keep this source http://zero01.blog.51cto.com/12831981/1977028

JDBC Frequently asked Questions

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.