
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java DatabaseMetaData getIdentifierQuoteString Method with Example
The getIdentifierQuoteString() method of the DatabaseMetaData interface retrieves and returns the retrieves the string used by the underlying database to quote SQL identifiers.
To retrieve the string used by the underlying database to quote SQL identifiers.
Make sure your database is up and running.
Register the driver using the registerDriver() method of the DriverManager class. Pass an object of the driver class corresponding to the underlying database.
Get the connection object using the getConnection() method of the DriverManager class. Pass the URL the database and, user name, password of a user in the database, as String variables.
Get the DatabaseMetaData object with respect to the current connection using the getMetaData() method of the Connection interface.
Finally get the IdentifierQuoteString used by the database, by invoking the getIdentifierQuoteString() method of the DatabaseMetaData interface .
Example
Following JDBC program establishes connection with MySQL database, retrieves and, displays the string used by the underlying database to quote SQL identifiers.
import java.sql.Connection; import java.sql.DatabaseMetaData; import java.sql.DriverManager; import java.sql.SQLException; public class DatabaseMetaData_getIdentifierQuoteString { public static void main(String args[]) throws SQLException { //Registering the Driver DriverManager.registerDriver(new com.mysql.jdbc.Driver()); //Getting the connection String mysqlUrl = "jdbc:mysql://localhost/mydatabase"; Connection con = DriverManager.getConnection(mysqlUrl, "root", "password"); System.out.println("Connection established......"); //Retrieving the meta data object DatabaseMetaData metaData = con.getMetaData(); //Retrieving the major version of the database String identifierQuoteString = metaData.getIdentifierQuoteString(); //Retrieves string used by the underlying database to quote SQL identifiers System.out.println("String used to quote the SQL identifiers: "+identifierQuoteString); } }
Output
Connection established...... Major version of the JDBC driver used: `