Found 4336 Articles for Java 8

How to process SQL statements with JDBC explain with an example?

Daniol Thomas
Updated on 30-Jul-2019 22:30:25

5K+ Views

To process an SQL statement, you need to follow the steps given below:Establish the connection.Create a statement.Execute the statement/query.Process the result.Close the connection.Establishing a ConnectionTo process SQL statements first of all you need to establish connection with the desired DBMS or, file System or, other data sources.To do so, Register the JDBC driver class, corresponding to the DataSource you need to the DriverManager using the registerDriver() method.Driver myDriver = new com.mysql.jdbc.Driver(); DriverManager.registerDriver(myDriver);This method accepts an object of the Driver class; it registers the specified Driver with the DriverManager.You can also register the driver using the forName() method. This method loads ... Read More

How to print XPath Expression result in JSP?

Samual Sam
Updated on 30-Jul-2019 22:30:25

263 Views

The tag displays the result of an XPath expression. It functions the same as JSP syntax.AttributeThe tag has the following attributes −AttributeDescriptionRequiredDefaultselectXPath expression to evaluate as a string, often using XPath variablesYesNoneescapeXmlTrue if the tag should escape special XML charactersNotrueExampleLet us take an example which will cover the tags (a) , (b) .           JSTL x:out Tags               Books Info:                                                 ... Read More

How to parse an XML in JSP?

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

722 Views

The tag is used to parse the XML data specified either via an attribute or in the tag body.AttributeThe tag has the following attributes −AttributeDescriptionRequiredDefaultvarA variable that contains the parsed XML dataNoNonexmlText of the document to parse (String or Reader)NoBodysystemIdThe system identifier URI for parsing the documentNoNonefilterThe filter to be applied to the source documentNoNonedocXML document to be parsedNoPagescopeScope of the variable specified in the var attributeNoPagevarDomA variable that contains the parsed XML dataNoPagescopeDomScope of the variable specified in the varDom attributeNoPageExampleThe following example shows how parse can be used to read the external XML file −We have ... Read More

Is there any JSTL library to parse XML in a JSP?

Samual Sam
Updated on 30-Jul-2019 22:30:25

150 Views

The JSTL XML tags provide a JSP-centric way of creating and manipulating the XML documents. Following is the syntax to include the JSTL XML library in your JSP.The JSTL XML tag library has custom tags for interacting with the XML data. This includes parsing the XML, transforming the XML data, and the flow control based on the XPath expressions.Before you proceed with the examples, you will need to copy the following two XML and XPath related libraries into your \lib −XercesImpl.jar − Download it from https://www.apache.org/dist/xerces/j/xalan.jar − Download it from https://xml.apache.org/xalan-j/index.htmlRead More

How do I find out whether the underlying database supports batch processing?

Daniol Thomas
Updated on 30-Jul-2019 22:30:25

204 Views

Not all the databases support batch processing therefore before proceeding with batch updates in your application. You need to verify whether the database you are trying to communicate supports batch processing/batch updates or not.You can do so using the supportsBatchUpdates() method of the DatabaseMetaData interface.Follow the steps given below:Register the driver class using the registerDriver() method of the DriverManager class. Pass the driver class name to it, as a parameter.Connect to the database using the getConnection() method of the DriverManager class. Passing URL (String), username (String), password (String) as parameters to it.Create a DatabaseMetaData object using the getMetaData() method of ... Read More

How to group queries using transaction in a JSP?

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

187 Views

The tag is used to group the and tags into transactions. You can put as many and tags as statements inside the tag to create a single transaction.It ensures that the database modifications performed by the nested actions are either committed or rolled back if an exception is thrown by any nested action.AttributeThe tag has the following attributes −AttributeDescriptionRequiredDefaultdataSourceDatabase connection to use (overrides the default)NoDefault databaseisolationTransaction isolation (READ_COMMITTED, READ_UNCOMMITTED, REPEATABLE_READ, or SERIALIZABLE)NoDatabase’s defaultExampleTo start with the basic concept, let us create a Students table in the TEST database and create a few records ... Read More

Write an example JDBC program demonstrating the batch processing with CallableStatement object?

Daniol Thomas
Updated on 30-Jul-2019 22:30:25

646 Views

Grouping related SQL statements into a batch and executing/submitting them at once is known as batch processing. The Statement interface provides methods to perform batch processing such as addBatch(), executeBatch(), clearBatch().Follow the steps given below to perform batch updates using the CallableStatement object:Register the driver class using the registerDriver() method of the DriverManager class. Pass the driver class name to it, as a parameter.Connect to the database using the getConnection() method of the DriverManager class. Passing URL (String), username (String), password (String) as parameters to it.Set the auto-commit to false using setAutoCommit() method of the Connection interface.Create a CallableStatement object ... Read More

How to pass a date variable in sql query in a JSP?

Samual Sam
Updated on 30-Jul-2019 22:30:25

913 Views

The tag is used as a nested action for the and the tag to supply a date and time value for a value placeholder. If a null value is provided, the value is set to SQL NULL for the placeholder.AttributeThe tag has the following attributes −AttributeDescriptionRequiredDefaultValueValue of the date parameter to set (java.util.Date)NoBodytypeDATE (date only), TIME (time only), or TIMESTAMP (date and time)NoTIMESTAMPExampleTo start with basic concept, let us create a simple table Students table in the TEST database and create a few records in that table as follows −Step 1Open a Command Prompt and change ... Read More

Write an example JDBC program demonstrating the batch processing with PreparedStatement object?

Daniol Thomas
Updated on 30-Jul-2019 22:30:25

120 Views

Grouping related SQL statements into a batch and executing/submitting them at once is known as batch processing. The Statement interface provides methods to perform batch processing such as addBatch(), executeBatch(), clearBatch().Follow the steps given below to perform batch updates using the PreparedStatement object:Register the driver class using the registerDriver() method of the DriverManager class. Pass the driver class name to it, as a parameter.Connect to the database using the getConnection() method of the DriverManager class. Passing URL (String), username (String), password (String) as parameters to it.Set the auto-commit to false using setAutoCommit() method of the Connection interface.Create a PreparedStatement object ... Read More

How to use parameterized SQL query in a JSP?

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

941 Views

The tag used as a nested action for the tag and the tag to supply a value for a value placeholder. If a null value is provided, the value is set to SQL NULL for the placeholder.AttributeThe tag has the following attributes −AttributeDescriptionRequiredDefaultValueValue of the parameter to setNoBodyExampleTo start with the basic concept, let us create an Employees table in the TEST database and create few records in that table as follows −Step 1Open a Command Prompt and change to the installation directory as follows −C:\> C:\>cd Program Files\MySQL\bin C:\Program Files\MySQL\bin>Step 2Login to the database as ... Read More

Advertisements