
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

543 Views
In this article, we will learn to close resources automatically in Java. Resource management becomes important in Java programming to prevent memory leaks and system instability. Java provides several options for closing resources automatically: files, database connections, and network sockets. The Problem with Manual Resource Closure Traditionally, developers needed to manually close resources using try-finally blocks. This method is error-prone because it's easy to forget to close resources, and exception handling can be complicated: FileInputStream fis = null; try { fis = new FileInputStream("file.txt"); } finally { if (fis != null) { ... Read More

962 Views
SQL databases provide a datatype named Blob (Binary Large Object) in this, you can store large binary data like images.To retrieve binary (stream) values from a table JDBC provides a method called getBinaryStream() in the PreparedStatement interface.It accepts an integer representing the index of the column of the table and retrieves the binary data from it.You can retrieve binary data from a table using this method as shown below −FileInputStream fin = new FileInputStream("javafx_logo.jpg"); pstmt.setBinaryStream(3, fin);ExampleLet us create a table with name tutorials_data in MySQL using the CREATE statement as shown below −CREATE TABLE tutorials_data( Name VARCHAR(255), Type ... Read More

1K+ Views
SQL databases provide a datatype named Blob (Binary Large Object) in this, you can store large binary data like images.To store binary (stream) values into a table JDBC provides a method called setBinaryStream() in the PreparedStatement interface.It accepts an integer representing the index of the bind variable representing the column that holds values of type BLOB, an InputStream object holding the binary data and, inserts the given data in to the specified column.You can insert binary stream data into a table using this method as shown below −FileInputStream fin = new FileInputStream("javafx_logo.jpg"); pstmt.setBinaryStream(3, fin);ExampleLet us create a table with name ... Read More

429 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..MySQL does not provide any separate datatype to store DATALINK/URL value you need to store using TEXT or VARCHAR datatypes as shown in the following query −CREATE TABLE tutorials_data ( tutorial_id INT PRIMARY KEY AUTO_INCREMENT, tutorial_title VARCHAR(100), tutorial_author VARCHAR(40), submission_date date, tutorial_link VARCHAR(255) );Following JDBC program establishes a connection with MYSQL database, creates a table with name tutorials_data. In this table we are creating a column with name tutorial_link which stores ... Read More

1K+ Views
focus()Javascript focus() methods helps to highlight a HTML form element. It sets the element as an active element in the current document. In current documentation, focus can be applied to only one single element. The focus can be applied either to a text, a button, etc. syntaxelement.focus(options);ExampleIn the following example, initially, the text "Tutorialspoint" is in an anchor tag 'a', which as an id called 'focus'. Later on, a function is declared in which the id is called using a DOM method and focus() method is applied on it to change the color of text "Tutorialspoint" to red. Here a button ... Read More

1K+ Views
Java provides supporting classes/datatypes to store all the MySQL datatypes, following is the table which list outs the respective java types for MySQL datatypes −MySQL TypeJava TypeCHARStringVARCHARStringLONGVARCHARStringNUMERICjava.math.BigDecimalDECIMALjava.math.BigDecimalBITbooleanTINYINTbyteSMALLINTshortINTEGERintBIGINTlongREALfloatFLOATdoubleDOUBLEdoubleBINARYbyte []VARBINARYbyte []LONGVARBINARYbyte []DATEjava.sql.DateTIMEjava.sql.TimeTIMESTAMPjava.sql.TiimestampExampleFollowing JDBC program creates a table with name sample with all the possible datatypes in MySQL −import java.sql.Connection; import java.sql.DriverManager; import java.sql.Statement; public class CreatingTable_AllDatatypes { public static void main(String args[])throws Exception { //Registering the Driver DriverManager.registerDriver(new com.mysql.jdbc.Driver()); //Getting the connection String mysqlUrl = "jdbc:mysql://localhost/sampledatabase"; Connection con = DriverManager.getConnection(mysqlUrl, "root", "password"); System.out.println("Connection ... Read More

470 Views
The ResultSetMetadata class provides various methods that gives information about the current ResultSet object such as number of columns, name of the table, name of the column, datatype of the column etc…To prepare a CREATE query you need to get −Name of the table, using the getTableName() method.Column count, to iterate the columns using the getColumnCount() method.Name of the each column using the getColumnName() method.Data type of each column using the getColumnTypeName() method.Precision of each column using the getPrecision() method.ExampleLet us create a table with name customers in MySQL database using the CREATE query as shown below −CREATE TABLE Customers ... Read More

5K+ Views
The main difference between JTextField and JTextArea in Java is that a JTextField allows entering a single line of text in a GUI application while the JTextArea allows entering multiple lines of text in a GUI application. JTextField The following are the key characteristics of JTextField in Java: A JTextFeld is one of the most important components that allow the user to an input text value in a single line format. A JTextField will generate an ActionListener interface when we trying to enter some input inside it. The JTextComponent is a superclass of JTextField that provides a common set ... Read More

187 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

198 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