
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
Found 9150 Articles for Object Oriented Programming

296 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

746 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

684 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

673 Views
GeneratorsJavaScript supports Generator functions and Generator Objects. A generator function is the same as a normal function, but whenever it needs to generate a value it uses the 'yield' keyword rather than 'return'. The 'yield' keyword halts the function execution and sends a value back to the caller. It has an ability that it can resume the functionality from where it is left off. syntaxfunction* generator(){ yeild 1; yeild 2; }ExampleIn the following example, using a generator function, natural numbers 10, 9 and 8 were printed. Instead of printing each number individually we can run ... Read More

2K+ Views
JFrameThe components added to the frame are referred to as its contents, these are managed by the contentPane. To add a component to a JFrame, we must use its contentPane instead.A JFrame contains a window with title, border, (optional) menu bar and user-specified components.A JFrame can be moved, resized, iconified and it is not a subclass of JComponent.By default, JFrame is displayed in the upper-left corner of the screen. To display a frame at a specified location, we can use the setLocation(x, y) method in the JFrame class.Exampleimport java.awt.*; import java.awt.event.*; import javax.swing.*; public class JFrameDemo { public static void main(String s[]) { ... Read More