Found 2616 Articles for Java

How to make a MySQL Connection in JAVA? What is the port number to set on locahost?

AmitDiwan
Updated on 16-Dec-2019 05:57:57

379 Views

You need to use port number 3306 in the URL. The syntax is as follows −jdbc:mysql://localhost:3306Exampleimport java.sql.Connection; import java.sql.DriverManager; public class MySQLConnectionToJava {    public static void main(String[] args) {       String JDBCURL="jdbc:mysql://localhost:3306/sample?useSSL=false";       Connection con=null;       try {          con = DriverManager.getConnection(JDBCURL,"root","123456");         if(con!=null) {             System.out.println("MySQL connection is successful with port 3306.");           }     }     catch(Exception e) {       e.printStackTrace();     } } }OutputMySQL connection is successful with port 3306.

Can I learn Selenium without knowing Java?

Adiya Dua
Updated on 11-Dec-2019 12:38:47

457 Views

This Question comes to many professionals who are not actually into core technical and want to pursue their career in Selenium Automation. The term coding makes the non-programmers a bit scare to even start off with something like automation. There is a perception that a non-programmer cannot excel in Automation, but it is only in head. Many deserving and capable manual testers shy away from Selenium just thinking that it require some special skills.There are various many languages in which Selenium Scripts are designed such as Python, Ruby, C#, JavaScript and Java is one such of them. Knowing the popularity ... Read More

Count the number of columns in a MySQL table with Java

AmitDiwan
Updated on 11-Dec-2019 06:37:17

290 Views

For this, use ResultSetMetaData. Let us first create a table −mysql> create table DemoTable    -> (    -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> StudentFirstName varchar(20),    -> StudentLastName varchar(20)    -> ); Query OK, 0 rows affected (0.58 sec)The Java code is as follows −Exampleimport java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.Statement; import com.mysql.jdbc.ResultSetMetaData; public class ResultSetDemo {    public static void main(String[] args) {       Connection con = null;       PreparedStatement ps = null;       Statement st = null;       ResultSet rs = null; ... Read More

Difference between Go and Java.

Mahesh Parahar
Updated on 28-Nov-2019 10:45:07

296 Views

GoGo is a procedural programming language. Programs are assembled using packages. It supports environment adopting patterns similar to dynamic languages.JavaJava is an object oriented programming language. Java is quiet fast, reliable and secure. It is most widely used language as well.Following are the important differences between Go and Java.Sr. No.KeyGoJava1TypeGo is a procedural programming language and supports patterns similar to dynamic languages.Java is an object oriented programming language.2Supports for ClassGo has no support for class with constructors.Java has support for class with constructors.3Exception HandlingGo has error handling instead of exception handling.Java has exception handling.4InheritanceGo has no support for inheritance.Java supports ... Read More

Difference between Association and Aggregation in Java

Mahesh Parahar
Updated on 28-Nov-2019 10:16:56

7K+ Views

AssociationAssociation in terms of objects refers to "has a" relationship between two related objects. For example, a employee has a communication address.class Employee {    String name;    Address communicationAddress; } class Address {    String address; }AggregationAggregation in terms of objects refers to "has a"+ relationship between two related objects. For example, a department has multiple employees. It refers to having a collection of child objects in parent class. For example:class Department {    String name;    List employees; } class Employee {    String name; }Sr. No.KeyAssociationAggregation1DefinitionAssociation refers to "has a" relationship between two classes which use each ... Read More

Differences between Difference between getc(), getchar(), getch() and getche() functions

Mahesh Parahar
Updated on 26-Nov-2019 10:42:58

911 Views

All of these functions are used to get character from input and each function returns an integer signifying the status code as well.Following are the important differences between getc(), getchar(), getch() and getche() functions.getc()getc() can read characters from any stream. Returns EOF on failure.Syntaxint getc(FILE *stream);getchar()getchar() can read characters from standard input only.Syntaxint getchar();getch()getch() can read characters from standard input but it does not use any buffer and returns immidately without waiting for enter key pressed.Syntaxint getch();getche()getche() behaves similar to getch() as it can read characters from standard input and it does not use any buffer and returns immidately without ... Read More

Differences between ArrayList and LinkedList in Java

Mahesh Parahar
Updated on 07-Dec-2023 10:15:10

23K+ Views

Both ArrayList and LinkedList are implementation of List interface in Java. Both classes are non-synchronized. But there are certain differences as well. Following are the important differences between ArrayList and LinkedList method. Sr. No. Key ArrayList LinkedList 1 Internal Implementation ArrayList internally uses a dynamic array to store its elements. LinkedList uses Doubly Linked List to store its elements. 2 Manipulation ArrayList is slow as array manipulation is slower. LinkedList is faster being node based as not much bit shifting required. 3 Implementation ArrayList implements only List. LinkedList implements List as well as Queue. It can acts as a queue as well. 4 Access ArrayList is faster in storing and accessing data. LinkedList is faster in manipulation of data. Example of ArrayList ... Read More

Differences between Interface and class in Java

Mahesh Parahar
Updated on 07-Dec-2023 11:54:40

20K+ Views

Class A class is a blueprint from which individual objects are created. A class can contain any of the following variable types. Local Variables − Variables defined inside methods, constructors or blocks are called local variables. The variable will be declared and initialized within the method and the variable will be destroyed when the method has completed. Instance Variables − Instance variables are variables within a class but outside any method. These variables are initialized when the class is instantiated. Instance variables can be accessed from inside any method, constructor or blocks of that particular class. Class Variables − Class variables are variables declared ... Read More

Difference between Constructors and Methods in Java

Mahesh Parahar
Updated on 08-Dec-2023 10:19:00

19K+ Views

Constructors are special methods used to initialize objects whereas methods are used to execute certain statements. Following are the important differences between Constructors and Methods. Sr. No. Key Constructors Methods 1 Purpose Constructor is used to create and initialize an Object. Method is used to execute certain statements. 2 Invocation A constructor is invoked implicitly by the System. A method is to be invoked during program code. 3 Invocation A constructor is invoked when new keyword is used to create an object. A method is invoked when it is called. 4 Return Type A constructor can not have any return type. A method can have a return type. 5 Object A constructor initializes an object which is not existent. A method can be invoked ... Read More

Difference between Scanner and BufferReader Class in Java

Mahesh Parahar
Updated on 26-Nov-2019 10:20:58

10K+ Views

Scanner and BufferReader both classes are used to read input from external system. Scanner is normally used when we know input is of type string or of primitive types and BufferReader is used to read text from character streams while buffering the characters for efficient reading of characters. Following are the important differences between Scanner class and a BufferReader class.Sr. No.KeyScanner ClassBufferReader Class1SynchronousScanner is not syncronous in nature and should be used only in single threaded case.BufferReader is syncronous in nature. During multithreading environment, BufferReader should be used.2Buffer MemoryScanner has little buffer of 1 KB char buffer.BufferReader has large buffer ... Read More

Advertisements