
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
Programming Articles - Page 2556 of 3366

193 Views
The class named Types of the java.sql package contains the constants that represents the SQL datatypes. All these datatypes are represented by unique integer values.Retrieving the integer values from the Types classTo print all the class names and values of the constants in java.sql.Types class −Retrieve all the fields in Types class − The getFields() method of the class Class returns an array which holds all the fileds (public) of the class/interface represented by the current Class object.Using this method retrieve the array of fileds of the Types class as shown below −Field[] fields = java.sql.Types.class.getFields();Retrieve the name and value ... Read More

206 Views
A DATALINK object represents an URL value which refers to an external resource (outside the current database/data source), which can be a file, directory etc..You can retrieve a DATALINK object an SQL table using the getURL() method of the PreparedStatement interface. This method accepts an integer value representing an index of the column in the ResultSet and returns the URL object in the specified index.ExampleLet us create a table with name tutorials_data in MySQL database using CREATE statement as shown below −CREATE TABLE tutorials_data ( tutorial_id INT PRIMARY KEY AUTO_INCREMENT, tutorial_title VARCHAR(100), tutorial_author VARCHAR(40), submission_date date, ... Read More

300 Views
A DATALINK object represents an URL value which refers to an external resource (outside the current database/data source), which can be a file, directory etc.You can store a DATALINK into an SQL table using the setURL() method of the PreparedStatement interface. This method accepts an integer value representing an index of the bind variable, an URL object and, inserts the given URL object in the column represented by the bind variable in the specified index.ExampleLet us create a table with name tutorials_data in MySQL database using CREATE statement as shown below −CREATE TABLE tutorials_data ( tutorial_id INT PRIMARY KEY ... Read More

759 Views
Initially, till Java6 it is needed to register the driver using Class.forname() or the registerDriver() method before establishing connection with the database.But, since Java 1.6, JDBC 4.0 API, there is no need to register the driver explicitly, You Just need to set the Class path for the JDBC 4.X driver, Java automatically detects the Driver class and loads it.ExampleIn the following JDBC program we are trying connect with MySQL database first of all include the dependency for the MySQL driver in the pom.xml of your project. mysql mysql-connector-java 8.0.16 Then, without registering the MySQL driver class com.mysql.jdbc.Driver ... Read More

4K+ Views
The java.time package of Java8 provides a class named LocalDateTime is used to get the current value of local date and time. Using this in addition to date and time values you can also get other date and time fields, such as day-of-year, day-of-week and week-of-year.Converting java.sql.Date to LocalDateTimeThe java.sql.TimeStamp class provides a method with name toLocalDateTime() this method converts the current timestamp object to a LocalDateTime object and returns it.To convert date to LocalDateTime object.Create a Timestamp object from Date object using the getTime() method as −Date date = rs.getDate("DispatchDate"); //Converting Date to Timestamp Timestamp timestamp = new Timestamp(date.getTime());Now, ... Read More

4K+ Views
The java.time package of Java provides a class named LocalDateTime is used to get the current value of local date and time. Using this in addition to date and time values, you can also get other date and time fields, such as day-of-year, day-of-week, and week-of-year. Setting the Local time to a column To set the local date and time value to a column in a table. Obtain the LocalDateTime object: You can obtain the LocalDateTime object by invoking the static method now() as: LocalDateTime localDateTime = LocalDateTime.now(); Get the LocalDate and LocalTime objects from the above obtained LocalDateTime as: ... Read More

2K+ Views
A transaction is a unit of work that is performed against a database. Transactions are units or sequences of work accomplished in a logical order, whether in a manual fashion by a user or automatically by some sort of a database program.A transaction is the propagation of one or more changes to the database. For example, if you are creating a record or updating a record or deleting a record from the table, then you are performing a transaction on that table. It is important to control these transactions to ensure the data integrity and to handle database errors.Ending a ... Read More

17K+ Views
A database script file is a file that contains multiple SQL quries separated from each other. Usually, these files have the .sql extention.Running .sql script files in JavaYou can execute .sql script files in Java using the runScript() method of the ScriptRunner class of Apache iBatis. To this method you need to pass a connection object.Therefore to run a script file −Register the MySQL JDBC Driver using the registerDriver() method of the DriverManager class.Create a connection object to establish connection with the MySQL database using the getConnection() method.Initialize the ScriptRunner class of the package org.apache.ibatis.jdbc.Create a Reader object to read ... Read More

5K+ Views
Whenever, we instantiate and use certain objects/resources we should close them explicitly else there is a chance of Resource leak.Generally, we used close resources using the finally block as −Connection con = null; Statement stmt = null; ResultSet rs = null; //Registering the Driver try { con = DriverManager.getConnection(mysqlUrl, "root", "password"); stmt = con.createStatement(); } catch (SQLException e) { e.printStackTrace(); } finally { try { rs.close(); stmt.close(); con.close(); } catch(SQLException e) { e.printStackTrace(); } }From JSE7 onwards the try-with-resources statement is ... Read More

707 Views
JWindow is a Swing component that is used to create a splash screen easily as splash screen as it displays a screen without a title bar or window management buttons. In this article, we will learn to implement a splash screen using JWindow in Java. What is a JWindow? A JWindow is a container that can be displayed anywhere on the user's desktop. It does not have the title bar, window management buttons, etc, like a JFrame. The JWindow contains a JRootPane as its only child class. The contentPane can be the parent of any children of the JWindow. Like a ... Read More