How To Write Named Parameterized Query In Java

How To Write Named Parameterized Query In Java

In java, creating parametrized query is not so easy for big queries as JAVA JDBC API interface PreparedStatement only supports passing parameters by index.  To overcome this limitation we are going to create our custom classes that will enable us to pass parameters to the query by name. Let's take a look at what's the problem in hand and then we'll talk about the soluion. Why do we need Perameterized Query? In java, to execute an sql query we have to create statement and then we can execute that statement to select, insert, upd...

Continue Reading...

How To Create Connection To MySQL, PosgreSQL & Oracle Databases In Java Using JDBC

How To Create Connection To MySQL, PosgreSQL & Oracle Databases In Java Using JDBC

There are multiple ways to create database connection using JDBC API in java. But, here we are going to see most used and recommended ways to create database connection to MySQL, PostgreSQL & Oracle databases. There's just only five steps you need to follow for any database -  Download vendor (MySQL, PostgreSQL & Oracle etc.) specefic driver jar from their website Add that jar in your project's library/classpath Load that driver in your application Create connection-string / connection-url Get ...

Continue Reading...

Java String: From Basics To Advance

Java String: From Basics To Advance

Here, we are going to discuss – What is String? String declaration String Initialization String declaration and initialization in a single line Multiple strings in a single line String Class Difference Between String s = new String("codemeright") and String s = "codemeright" Most used String functions   What is String? A String in Java is a sequence of characters enclosed in double quotes. These are also called string literals....

Continue Reading...

Mutability & Immutability In Java

Mutability & Immutability In Java

In Java, classes can be mutable or immutable. But what does it mean by mutable or immutable? Let us try to understand it by step-by-step explanation. Here, we are going to cover – What is mutability? What is immutability? Create your own immutable class What is the difference between immutable & final? Conclusion   What is mutability? The word mutable means changeable. If an object of a class can be changed, then this class is called mutable class. In simple words, if you can...

Continue Reading...

Java 8 Stream Explained With Examples

Java 8 Stream Explained With Examples

If you want to perform some actions on a collections object for example: filtering, sorting or manipulating each element on that object based on some condition, you can use the java 8 stream feature to complete your requirement easily with less code. It dosen't mean that you cannot achieve your requirement without Stream. But with Stream, it takes less lines of code to achieve your requirement and your program becomes more readable. Let us now try to understand the concept with some examples -  Syntax You can get a str...

Continue Reading...