Found 4336 Articles for Java 8

Java Connection getSystemFunctions() method with example

Vikyath Ram
Updated on 30-Jul-2019 22:30:26

86 Views

This method retrieves the list of System functions supported by the current database. The names returned by this method are the Open CLI System function names.This method returns a String value holding the list of functions separated by commas (", ").To get the list of the System functions supported by the underlying database −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 ... Read More

Java Connection getStringFunctions() method with example

Vikyath Ram
Updated on 30-Jul-2019 22:30:26

209 Views

The getStringFunctions() method of the Connection interface retrieves the list of String functions supported by the current database. The names returned by this method are the Open CLI String function names.This method returns a String value holding the list of functions separated by commas (", ").To get the list of the String functions supported by the underlying database −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 ... Read More

Java Connection getNumeric() method with example

Vikyath Ram
Updated on 30-Jul-2019 22:30:26

142 Views

The getNumeric() method of the Connection interface retrieves the list of math functions supported by the current database. The names returned by this method are the Open CLI math function names.This method returns a String value holding the list of functions separated by commas (", ").To get the list of the numeric functions supported by the underlying database −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 ... Read More

Java Connection commit() method with example

Vikyath Ram
Updated on 30-Jul-2019 22:30:26

5K+ Views

The commit() method of the Connection interface saves all the modifications made since the last commit.con.save()If any issue occurs after the commit you can revert all the changes done till this commit by invoking the rollback() method.Con.rollback()To commit a transactionRegister the driver using the registerDriver() method of the DriverManager class as −//Registering the Driver DriverManager.registerDriver(new com.mysql.jdbc.Driver());Get the connection using the getConnection() method of the DriverManager class as −//Getting the connection String url = "jdbc:mysql://localhost/mydatabase"; Connection con = DriverManager.getConnection(url, "root", "password");Turn off the auto-commit using the setAutoCommit() method as −//Setting the auto commit false con.setAutoCommit(false);Commit the transaction using the commit() method as −con.commit();Let us create a table with ... Read More

Java Connection setTransactionIsolation() method with example

Arushi
Updated on 05-Jul-2024 17:40:49

2K+ Views

In a database system, where more than one transaction is being executed simultaneously and in parallel, the property of isolation states that all the transactions will be carried out and executed as if it is the only transaction in the system. No transaction will affect the existence of any other transaction. Transaction Isolation Levels in Java Connection JDBC (Java Database Connectivity) provides support 5 transaction isolation levels through Connection interface. TRANSACTION_NONE: It is represented by integer value 0 does not support transactions. TRANSACTION_READ_COMMITTED: It is represented by integer value 2 supports ... Read More

Java Connection getTransactionIsolation() method with example

Rishi Raj
Updated on 30-Jul-2019 22:30:26

458 Views

In a database system where more than one transaction is being executed simultaneously and in parallel, the property of isolation states that all the transactions will be carried out and executed as if it is the only transaction in the system. No transaction will affect the existence of any other transaction.JDBC provides support 5 transaction isolation levels through Connection interface.TRANSACTION_NONE: It is represented by integer value 0 does not support transactions.TRANSACTION_READ_COMMITTED: It is represented by integer value 2 supports transactions allowing Non-Repeatable Reads and, Phantom Reads.TRANSACTION_READ_UNCOMMITTED: It is represented by integer value 1 supports transactions allowing Dirty Reads, Non-Repeatable Reads ... Read More

Java Connection getClientInfo() method with example

Arushi
Updated on 30-Jul-2019 22:30:26

1K+ Views

The getClientInfo() method of the Connection interface returns the name and values of the client info properties of the current connection. This method returns a properties object.To retrieve the values of the client info properties file.Register the driver using the registerDriver() method of the DriverManager class as −//Registering the Driver DriverManager.registerDriver(new com.mysql.jdbc.Driver());Get the connection using the getConnection() method of the DriverManager class as −//Getting the connection String url = "jdbc:mysql://localhost/mydatabase"; Connection con = DriverManager.getConnection(url, "root", "password");Create a properties object as −Properties properties = new Properties();Add the required key-value pairs to the above created Properties object as −properties.put("user_name", "new_user"); properties.put("password", "password");Set the above ... Read More

Java Connection The setClientInfo() method with example

Vikyath Ram
Updated on 30-Jul-2019 22:30:26

750 Views

The setClientInfo() method of the Connection interface sets values to the client info properties of the current connection object.ParametersThis method accepts a Properties object as a parameter.con.setClientInfo(properties);To set values to the client info properties file.Register the driver using the registerDriver() method of the DriverManager class as −//Registering the Driver DriverManager.registerDriver(new com.mysql.jdbc.Driver());Get the connection using the getConnection() method of the DriverManager class as −//Getting the connection String url = "jdbc:mysql://localhost/mydatabase"; Connection con = DriverManager.getConnection(url, "root", "password");Create a properties object as −Properties properties = new Properties();Add the required key-value pairs to the above created Properties object as −properties.put("user_name", "new_user"); properties.put("password", "password");Set the above created ... Read More

How to establish a connection with the database using the properties file in JDBC?

Rishi Raj
Updated on 30-Jul-2019 22:30:26

1K+ Views

One of the variant of the getConnection() method of the DriverManager class accepts url of the database, (String format) a properties file and establishes connection with the database.Connection con = DriverManager.getConnection(url, properties);To establish a connection with a database using this method −Set the Driver class name as a system property −System.setProperty("Jdbc.drivers", "com.mysql.jdbc.Driver");Create a properties object as −Properties properties = new Properties();Add the user name and password to the above created Properties object as −properties.put("user", "root"); properties.put("password", "password");Finally invoke the getConnection() method of the DriverManager class by passing the URL and, properties object as parameters.//Getting the connection String url = "jdbc:mysql://localhost/mydatabase"; Connection con = ... Read More

Java Connection getMetaData() method with example

Arushi
Updated on 30-Jul-2019 22:30:26

2K+ Views

Generally, Data about data is known as metadata. The DatabaseMetaData interface provides methods to get information about the database you have connected with like, database name, database driver version, maximum column length etc...The getMetaData() method of the Connection interface retrieves and returns the DatabaseMetaData object. This contains information about the database you have connected to. You can get information about the database such as name of the database, version, driver name, user name and, url etc… by invoking the methods of the DatabaseMetaData interface using the obtained object.This method returns the DatabaseMetaData object which holds information about the underlying database.To get ... Read More

Advertisements