Thursday, 28 December 2023

Exploring the C# Ecosystem: Tools and Frameworks You Should Know

Welcome to a journey through the diverse and expansive landscape of the C# ecosystem. As developers, understanding the tools and frameworks available to us is crucial for building robust and efficient applications. In this blog post, we will delve into some of the key components that make up the rich tapestry of the C# programming world.

 

Visual Studio: The Powerhouse IDE

 

At the heart of C# development lies Visual Studio, Microsoft's powerful Integrated Development Environment (IDE). Whether you're working on a desktop application, a web project, or even mobile development with Xamarin, Visual Studio provides a feature-rich environment that enhances productivity and code quality.

 

.NET Framework and .NET Core

 

The .NET Framework has been a stalwart in the C# ecosystem for years, enabling the development of Windows applications. However, with the advent of .NET Core, developers gained a cross-platform, open-source framework for building modern, scalable applications. The unification of .NET 5 and later versions brought these frameworks together into the unified .NET platform.

 

ASP.NET: Building Web Applications

 

For web development with C#, ASP.NET is the go-to framework. With a model-view-controller (MVC) architecture and robust support for building RESTful APIs, ASP.NET empowers developers to create dynamic and responsive web applications. The introduction of Blazor also allows developers to build interactive web UIs using C# and .NET.

 

Entity Framework: Simplifying Database Access

 

Database interactions are a fundamental aspect of many applications. Entity Framework, an object-relational mapping (ORM) framework, simplifies database access in C# applications. With features like code-first development and automatic migrations, developers can focus more on application logic and less on database intricacies.

 

Xamarin: Cross-Platform Mobile Development

 

For those venturing into mobile app development, Xamarin provides a C#-based framework for building cross-platform applications. Leveraging a single codebase, developers can target both iOS and Android platforms, streamlining the development process and reducing time to market.

 

NUnit and xUnit: Testing Made Easy

 

No application is complete without a robust testing strategy. In the C# ecosystem, NUnit and xUnit stand out as popular testing frameworks. These tools facilitate the creation of unit tests, ensuring that your code is reliable and free from defects.

 

Avalonia and WinUI: Desktop App Development

 

For desktop application development, Avalonia and WinUI offer exciting possibilities. Avalonia is a cross-platform XAML-based UI framework, while WinUI provides a native UI platform for Windows applications. Both frameworks empower developers to create modern, visually appealing desktop applications using C#.

 

Conclusion

 

The C# ecosystem is a vast and dynamic realm, constantly evolving to meet the demands of modern software development. As you explore the tools and frameworks mentioned in this post, you'll discover the versatility and power that C# brings to the table. Whether you're building web applications, mobile apps, or desktop software, the C# ecosystem has the tools you need to bring your ideas to life. Happy coding! # Exploring the C# Ecosystem: Tools and Frameworks You Should Know

 

___________________________________________

 

Blog Written by: Aparnathi Dhavalgiri

 

___________________________________________

 

Learn all programming languages: youtube.com/avadhtutor

 

 

 

Sunday, 24 September 2023

Typography in Web Design: Choosing Fonts for Readability and Aesthetics

Typography plays a crucial role in web design, influencing how users perceive and interact with a website. The fonts you choose can significantly impact readability, aesthetics, and the overall user experience. In this blog post, we'll explore the importance of typography in web design and provide guidance on selecting fonts that enhance both readability and aesthetics of a website.

The Importance of Typography in Web Design

Typography is more than just selecting a font; it involves arranging and designing text to make it appealing and legible. When it comes to web design, effective typography is essential for several reasons:

1. Readability: The primary purpose of text is to be read and understood. Well-chosen fonts and proper typographic elements enhance the readability of the content, making it easier for users to consume the information.

2. Aesthetics: Typography contributes to the overall design aesthetics of a website. It helps convey the brand's personality, style, and message, creating a cohesive and visually pleasing user interface.

3. User Experience: A good typography choice can significantly improve the user experience. Clear and visually appealing text encourages users to stay longer on a website and engage with the content.

Tips for Choosing the Right Fonts

When selecting fonts for your website, consider the following tips to ensure both readability and aesthetics:

1. Understand the Brand and Audience: Start by understanding the brand's identity and target audience. Different fonts evoke different emotions and suit various brand personas. Tailor your font choices to align with the brand's voice and resonate with the intended audience.

2. Prioritize Readability: Readability should be a top priority. Choose fonts that are easy to read across various devices and screen sizes. Sans-serif fonts like Arial, Helvetica, or Roboto are often preferred for web body text due to their clean and legible characteristics.

3. Limit Font Choices: Avoid using too many different fonts, as it can create a cluttered and inconsistent look. Stick to a maximum of two or three fonts to maintain a cohesive design. Use one font for headings and another for body text to establish hierarchy and clarity.

4. Consider Contrast: Ensure sufficient contrast between the text and the background to enhance readability. Dark text on a light background or vice versa usually works well. High contrast improves accessibility for all users, including those with visual impairments.

5. Optimize for Different Devices: Test how your chosen fonts appear on various devices, including desktops, tablets, and smartphones. Ensure the fonts render well and maintain readability across different screen sizes and resolutions.

Conclusion

Typography is a fundamental element of web design that influences how users perceive and engage with your website. By choosing fonts that prioritize readability and align with your brand's aesthetics, you can create a visually appealing and user-friendly website. Remember to balance creativity with functionality to craft a compelling typographic experience for your users.

___________________________________________


Blog Written by: Aparnathi Dhavalgiri


___________________________________________

Learn all programming languages: youtube.com/avadhtutor

Thursday, 14 September 2023

CSS for Beginners: A Step-by-Step Guide

Starting with CSS as a beginner can be both exciting and rewarding. CSS (Cascading Style Sheets) is a fundamental language for web design, allowing you to control the visual appearance of your web pages. In this blog post, we'll guide you through the essential steps to begin your CSS journey.

Understanding the Basics

Before delving into CSS, it's crucial to grasp the foundational concepts:

1. HTML Knowledge: CSS works in tandem with HTML (Hypertext Markup Language), which defines the structure of your web page. Familiarize yourself with HTML tags and elements.

2. CSS Purpose: CSS is used to style HTML elements, specifying how they should appear on the screen. It encompasses properties like colors, fonts, spacing, and layout.

Setting Up Your Workspace

1. Text Editor: You can start writing HTML and CSS code with a simple text editor like Notepad (Windows) or TextEdit (Mac). However, consider using code editors designed for web development, such as Visual Studio Code, Sublime Text, or Atom, as they offer features like syntax highlighting and code suggestions.

2. Folder Structure: Organize your project files neatly. Create separate folders for HTML and CSS files to keep things organized.

Creating Your First HTML File

Begin by creating a basic HTML file. Here's a minimal example:

<!DOCTYPE html>

<html>

<head>

    <title>My First Web Page</title>

</head>

<body>

    <h1>Welcome to My Website</h1>

    <p>This is a paragraph of text.</p>

</body>

</html>

This HTML code defines a simple web page with a title, a heading (`<h1>`), and a paragraph (`<p>`).

Linking CSS to HTML

To apply CSS styles to your HTML, you'll need to link an external CSS file. Add this line inside the `<head>` section of your HTML file:

<link rel="stylesheet" type="text/css" href="styles.css">

This line tells the browser to load the `styles.css` file for styling.

Creating Your First CSS File

Now, create a new file named `styles.css` in the same directory as your HTML file. This is where you'll define your CSS styles.

Writing CSS Rules

In your `styles.css` file, you can start writing CSS rules. Here's an example:

/* styles.css */

h1 {

    color: blue;

    font-size: 24px;

}


p {

    color: green;

    font-size: 16px;

}

In this code, we're selecting the `<h1>` and `<p>` elements and applying styles to them. The CSS rules specify colors and font sizes.

Testing Your Work

Save both your HTML and CSS files. Open the HTML file in a web browser, and you should see your HTML content styled according to the CSS rules you defined.

Continuing Your Learning

- Experiment with different CSS properties and values to see how they affect your HTML elements.

- Practice by creating more complex layouts and styles as you become more comfortable with CSS.

- Utilize online resources like MDN Web Docs and W3Schools for in-depth tutorials and reference materials.

- Join web development communities and forums to seek help and share your progress with fellow learners.

Remember, learning CSS is an ongoing process, so be patient and persistent in your exploration of this essential web development skill. Happy coding!

____________________________________________

Blog Created by: Aparnathi Dhavalgiri

____________________________________________

Learn all programming languages: youtube.com/avadhtutor

Sunday, 10 September 2023

Responsive Web Design: Making Your Website Shine on Every Device

In today's digital age, people access websites on a lot of devices, from smartphones and tablets to laptops and desktops. As a website designer, it's important to make sure that your site looks good and functions smoothly on all of these devices. This is where responsive web design comes into play.


First of all, What Is Responsive Web Design?


Responsive web design is an approach that makes your website adapt and look great on any screen size or device. It's like having a web design that rearranges and resizes elements on your site to fit the screen perfectly. 

Now let us see how web design works:


Flexible Grid Layout: 

Responsive design uses a flexible grid system. Instead of fixed measurements in pixels, elements on your website are defined in units like percentages. This allows them to scale up or down as necessary.


Media Queries:

The most used tool or kit to create responsive design is media queries. These are like instructions that your website follows. They say things like, "If the screen width is less than 600 pixels, do this." Web designers use media queries to control how the site looks on all types of devices.


Fluid Images and Text:

Images and text also adapt to the screen size. They get larger or smaller so that they remain readable and visually stunning.


Now, let us take a peek at why Responsive Web Design actually Matters, let's talk about why it's so important:


User Experience: 

People don't like to pinch, zoom, and scroll endlessly to see your content. A responsive site provides a smooth and enjoyable experience for all visitors.


SEO Benefits:

Google prefers responsive websites. If your site isn't mobile-friendly, it may not rank as well in search results on mobile devices.


Increased Reach:

With responsive design, you reach a broader and wider audience. You're ready for visitors using any device, which can help you grow your website's traffic.


Now, let us see How to Implement Responsive Design:


Start with a Mobile-First Approach:

Design for mobile devices first. This ensures your site is functional and attractive on smaller screens.


Use CSS Media Queries:

Write CSS rules that specify how your site should look on various screen sizes. For example, you might set different font sizes for mobile and desktop.


Test Your Website across devices:

Test your site on different devices and browsers. Ensure everything looks good and works as expected.


Optimize Images:

Compress and optimize images to reduce load times on mobile devices.


Consider Touch Controls:

If your site has interactive elements, make sure they are touch-friendly for smartphones and tablets.


In Conclusion:

Responsive web design is like having a website that adapts to all devices. It provides a better user experience, helps with SEO, and helps increase audience reach. So, if you want your website to work and look good on all devices, make responsiveness a top priority in your web design efforts. Your visitors will thank you for it!

_____________________________________________________________________


Blog Written By: Aparnathi Dhavalgiri

_____________________________________________________________________


learn all programming languages at: https://www.youtube.com/@AvadhTutor

____________________________________________________________

Sunday, 3 September 2023

Do you know how A.I. works? AI: an awesome phenomenon

In this technology age and after the recent development and popularity gained by A.I.'s like ChatGPT and Midjourney, we often hear the word 'A.I.'

A.I., stands for Artificial intelligence and we all know that but have you ever thought how it works? Today we will break down how A.I. works in a simple manner using an easy to understand scenario.

Imagine you have a robot friend and you want this friend to do things you like. But the problem is this robot isn't smart like you.

This is where the A.I. comes. A.I. is like a special type of brain given to the machines so that they can think and make decisions themselves!

Lets try to understand how A.I. works in context of above scenario:

Learning

The A.I. will give your robot the ability to learn from different things. Just like you learn math or learn to play various games your robot will also learn from different examples and try figuring out stuff on its own

Thinking

With the help of A.I. your robot will be able to think and make decisions on its own. It will analyze the situation like a puzzle and try to solve it in best way possible even when it's encountering the puzzle for the first time!

Adapting

A.I. will make your robot adapt to each and everything it comes across.This way if it faces the same situation in the future it will be able to solve it in a better way.

Helping

The new AI brain will be helpful to you and your robot. For example finding the best route from a map, suggesting movies that we like, playing different games with us...It will do it all!

So here above we discussed how a.i. works using an example scenario. We can conclude that AI is a clever brain given to your machines which, in today's digital world, proves to be really helpful.


__________________________________________________


Blog Written by: Nishchay Joshi

_______________________________________________________

Learn all programming languages at: youtube.com/avadhtutor

Saturday, 2 September 2023

The Crucial Role of Core HTML in Design

In today's digital age, where websites and applications have become an integral part of our lives, design plays a pivotal role in capturing users' attention and delivering a seamless experience. While graphic design, user interface (UI), and user experience (UX) design receive a lot of attention, it's important not to overlook the fundamental building block of the web: HTML. Core HTML, the markup language that structures content on the internet, is the unsung hero of web design. Here, we explore the significance of core HTML in design.

Structural Foundation: HTML provides the structural foundation for a web page. It defines the essential elements such as headings, paragraphs, lists, images, links, and more. These elements create the basic structure of a webpage and serve as a canvas upon which designers can work their magic. Without a solid HTML structure, any design would lack coherence and functionality.

Accessibility: Accessibility in web design is paramount. Core HTML, when used correctly, ensures that your website is accessible to all users, including those with disabilities. Semantic HTML tags like headings, lists, and labels provide valuable cues to assistive technologies, making it easier for screen readers and other accessibility tools to interpret and convey the content accurately.

Search Engine Optimization (SEO): HTML is the language that search engine crawlers understand. Properly structured HTML with relevant tags, meta information, and semantic markup can greatly enhance a website's search engine ranking. A well-structured HTML document can make it easier for search engines to index your content and improve your site's visibility in search results.

Content Separation: HTML helps separate content from presentation. This separation is vital in modern web design, as it allows for greater flexibility and scalability. By using HTML to structure content and CSS to define its presentation, designers can easily change the look and feel of a website without altering the underlying content.

Responsive Design: In the era of mobile-first design, HTML's responsive capabilities are indispensable. Using HTML elements like `<div>`, `<section>`, and `<article>`, designers can create responsive layouts that adapt gracefully to various screen sizes and orientations. CSS can then be employed to style these layouts accordingly.

Cross-Browser Compatibility: HTML serves as a universal language that all browsers can interpret. By adhering to HTML standards, designers ensure that their websites are compatible with a wide range of browsers and devices, delivering a consistent experience to users across platforms.

Performance Optimization: Lightweight and well-structured HTML contributes to faster page loading times. It reduces unnecessary code bloat and enhances the overall performance of a website. Faster loading pages improve user satisfaction and can positively impact search rankings.

Future-Proofing: Core HTML evolves with the web. New HTML elements and features are regularly introduced to accommodate emerging technologies and trends. Staying up-to-date with HTML standards ensures that your design remains relevant and adaptable to the changing digital landscape.

In conclusion, while design elements like graphics, typography, and color schemes are crucial for creating visually appealing and user-friendly websites, it's essential not to underestimate the pivotal role of core HTML. It provides the structural framework upon which design is built, ensures accessibility, aids in SEO, promotes responsive design, enhances cross-browser compatibility, optimizes performance, and future-proofs your web presence. Embracing HTML as a design foundation is not just good practice; it's a fundamental requirement for successful web design in today's digital world.

___________________________________________________________


Post By: Aparnathi Dhavalgiri

___________________________________________________________

learn all programming languages at: https://www.youtube.com/@AvadhTutor

Friday, 1 September 2023

General Myths about SEO

In digital age where there is so much competition for online presence SEO(Search Engine Optimisation) has become a necessity for increasing your website's visitors and overall traffic in search engines like Google, Bing, Yahoo and yandex.

Here on we will discuss some of the common misconceptions surrounding the term SEO and the actual reality of them.


Myth #1: In SEO We optimise the Search Engine itself

Whether you are from I.T. or non-I.T. background you might know the full form of SEO and you may have thought, Seach Engine Optimisation means,"we will do something with google to optimise our site."

However it is crucial to know that in SEO you're going to optimise your site, not the Google itself.


Myth #2: Writing-style in SEO doesn't make a difference 

Google says that to rank your site and its content better, write it in a way that even a 6th grader can understand your content. 

That is the reason you should be careful about how you write your content. It makes a big difference!


Myth #3: The top-5 ranking in Search results is organic:

Today's world is full of competition. The top results in search engines often grab our attention. Companies like amazon and flipkart rely on advertising and paid-SEO. 

Therefore assuming that the top-5 ranking is organic and the content is reliable is a mistake.

On that note, here above we discussed some of the common misconceptions about SEO. Kindly comment down if you have any queries or suggestions.

_____________________

Post by: Nishchay Joshi

_____________________

Learn all programming with: youtube.com/avadhtutor

Wednesday, 15 February 2023

0001 0010 0100 1000 Pyramid Using PHP

 0001 0010 0100 1000 Pyramid Using PHP

<?php

$k=5;

 for($a=1;$a<=5;$a++)

 {

  for($b=1;$b<=5;$b++)

 {

  if($a==$b)

  {

  echo "1";

  }

  else

  {

  echo "0";

  }

 }

 echo "</br>";

} // design by dhara ripal pandya

?>

OUTPUT:

10000
01000
00100
00010
00001

_____________________________________

<?php

$k=6;

 for($a=0;$a<5;$a++)

 {

  $k--;

  for($b=1;$b<5;$b++)

  {

  if($k==$b)

  {

  echo "1";

  }

  else

  {

  echo "0";

  }

}

  echo "</br>";

 }

 //Developed By: My Wife (Dhara Ripal Pandya)

?>

OUTPUT:

0000
0001
0010
0100
1000

Thursday, 5 January 2023

Html Form with JavaScript (Odd Even, Sum of Sum, Addition, Reverse Number, factorial Number)

 

 JavaScript Factorial Number

<html>

<head>

<title>Form using Factorial - JavaScript </title>

<script>

function fact()

{

var n = parseInt(frm1.txt1.value);

var f=1;

for(a=1;a<=n;a++)

{

f = f*a;

}

document.writeln("Factorial = " + f);

}

</script>

</head>

<form name="frm1">

Enter Number : <input type="text" name="txt1"><br>

       <input type="button" name="btn1" value="Factorial" onClick="fact();">

</form>

</html>

____________________________

ODD EVEN NUMBER USING JAVA SCRIPT

<script>

function ifdemo()   

{

if(frm1.txt1.value%2==0)

{

document.write("This Number Is Even");

}

else

{

document.write("This Number Is Odd");

}

}

</script>

<form name=frm1>

Number 1 : <input type=text name=txt1><br>

  <input type=button name=btn1 value="Check" onClick="ifdemo();">

</form>

_____________________________

Reverse Number Printing Using JavaScript

<html>

<head>

<title> use of while loop</title>

<script languge="JavaScript">

function reverse()

{

/* Print Reverse Number */

var n = parseInt(frm1.txt1.value);

var rev=0,r;

while(n!=0)

{

r=n%10;

rev=rev*10+r;

n=Math.floor(n/10);

}

alert ("Reverse Number Is = "+rev);

}

</script>

</head>

<form name="frm1">

Enter Number : <input type="text" name="txt1"><br>

         <input type="button" name="btn1" value="Reverse" onClick="reverse();">

</form>

</html>

__________________________

Addition (SUM) Using JavaScript

<html>

<head>

<title> Use of JavaScript </title>

<script language="JavaScript">

function addition()

{

  a=parseInt(frm1.txt1.value);

b=parseInt(frm1.txt2.value);

c=a+b;

document.writeln ("Addition : " + c);

}

</script>

</head>

<form name=frm1>

    Enter Number 1 : <input type=text name=txt1><br>

    Enter Number 2 : <input type=text name=txt2><br>

                <input type=button name=btn1 value="Sum" onClick="addition();">

</form>

</html>

_______________________________

Sum of Sum Using JavaScript

<html>

<head>

<title> Do While Loop </title>

<script languge="JavaScript">

function sumofdigit()

{

/* Sum Of Digit */

var n = frm1.txt1.value;

var r,sum=0;

do

{

r=n%10;

sum=sum+r;

n=Math.floor(n/10);

}

while(n!=0);

frm1.txt2.value=sum;

}

</script>

</head>

<form name="frm1">

Enter Number : <input type="text" name="txt1" onblur="sumofdigit();"><br>

Sum Of Digit   : <input type="text" name="txt2"><br>

</form>

</html>

_______________________________

Swapping Values Using JavaScript


<script language="JavaScript">

function swap()

{

a=frm1.txt1.value; //10

frm1.txt1.value=frm1.txt2.value; //11

frm1.txt2.value=a; //10

}

</script>


<form name=frm1>

 <input type=text name=txt1><br>

 <input type=text name=txt2><br>

 <input type=button value="Swap" onClick="swap();">

</form>


____________________

learn All Programming with youtube.com/avadhtutor


















 


Monday, 22 August 2022

What is RMI? RMI Architecture

What is RMI:

    RMI – Remote Method Invocation.

    RMI allows object-to-object communication between different Java Virtual Machines (JVM).

    JVM can be distinct entities located on the same or separate computer.

    This enables applications to call object methods located remotely, sharing resources, and  processing     load across systems.

    Methods can even pass objects that a foreign virtual machine has never encountered before, allowing     the dynamic loading of new classes as required.

    In Java distributed object model, a remote object is one whose methods can be invoked from  another     JVM, potentially on a different host. An object of this type is described by one or more remote                interfaces, which are Java Interfaces that declare the methods of the remote object.  Remote Method     Invocation is the action of invoking a method of a remote interface on a remote object.

    RMI’S purpose is to make objects in separate JVM’S look and act like local objects. The JVM that        calls the remote object is usually referred to as a client and the JVM that contains the remote object is     the server. One of the most important aspects of the RMI design is its intended transparency.                Applications do not know whether an object is remote or local. A method invocation on a remote            object has the same syntax as a method invocation on a local object.

    A Remote object is always accessed via its remote interface. In the other words the client invokes            methods on the object only after casting the reference to the remote interface.


RMI Architecture: 

The RMI implementation is essentially built from three abstraction layers :

The Stub/Skeletons Layer :

This layer intercepts method calls made by the client to the interface reference and redirects these calls to a remote object. It is worth remembering that stubs are specific to the client side, whereas skeletons are found on the server side.

The Remote Reference Layer :

This layer handles the details relating to interpreting and managing references made by clients to the remote objects. It connects clients to remote objects that are running and exported on a server by a one-to one connection link.

The Transport Layer :

                This layer is based on TCP/IP connections between machines in a                                    network. It provides basic connectivity, as well as some firewall                                        penetration strategies.




--------------------------------------------------------------------------------

Explain Stub And Skeleton Briefly:

To achieve location transparency, RMI introduces two special kinds of objects known as

stubs and skeletons that serve as an interface between an application and the rest of the RMI

system.

            A stub is a client side proxy representing the remote object.

            A skeleton is a server side proxy that communicate with the stub.

            This layer’s purpose is to transfer data to the Remote Reference Layer via Marshaling and                        UN marshaling.

§ MARSHALING refers to the process of converting the data or object being transferred into a byte stream and UNMARSHALING is the reveres – converting the stream into an object or date. This conversion is achieved via object serialization.

§ The stub and skeleton layer of RMI lies just below the actual application and is based on the proxy design pattern.


    In the RMI use of proxy pattern, the stub class plays the role of the proxy for the remote service implementation.

    

    The skeleton is a helper class that is generated by RMI to help the object communicate

    with the  stub across the RMI link.

§     The skeleton carries on a conversation with the stub; it reads the parameters for the method          callfrom the link, makes the call to the remote service implementation object, accepts the return              value, and then writes the return value back to the stub.


S    STUB:

The stub is a client side object that represents the remote object. The stub has the same interface, or list of methods as the remote object. However, when the client calls a stub method, the stub forwards the request via the RMI infrastructure to the remote object (via skeleton), which actually executes it.

The following sequence of events performed by the stub in detail.

§     The stub is the client side proxy for the remote object.

§     Initiates a connection with the remote VM containing the remote object.

§     Marshals (write and transmits) the parameters to the remote VM.

§     Waits for the result of the method invocation.

§     Unmarshals (reads) the return value of exception returned.

§     Returns the value to the caller.

The stub hides the serialization of method parameters and the network level communication in order to present a simple invocation mechanism to the caller.The stub class must implement all the sameinterfaces as the remote object that it represents, it can be cast as any of those remote interface.The remote object may contain non-remote methods and fields, but these are not defined in any of the remote interface.

In the remote VM, each remote object may have a corresponding skeleton.


SKELETONS

On the server-side, the skeleton object takes care of all of the details of “remoteness” so that the actual remote object doesn’t need to worry about them.In other words, we can pretty much code a remote object the same way as if it were local; the skeleton insulates the remote object from the RMI infrastructure.During remote method requests, the RMI infrastructure automatically invokes the skeleton object so it can work its magic.

The following lists the sequence of events in detail;

§     The Skelton class stays on the server side of the connection and deals directly with the implementation classes of the remote methods being exported.

§     Unmarshals (reads) the parameters for the remote method (these were marshaled by the stub on the client side ).

§     Invokes the method on the actual remote object implementation.

§     Marshals (writes and transmits the result (return value or exception) to the caller (which is then unmarshaled by the stub.

The JDK contains the rmic tool that creates the class files for the stubs and skeletons.

--------------------------------------------------------------------





Wednesday, 27 July 2022

JDBC MYSQL Examples (Select, Insert, Update, Delete)

 Advance Java Tutorial here : https://youtube.com/playlist?list=PLkx9f4H3tJMI4735IyPUp88bKCvatY2IY


DOWNLOAD MYSQL CONNECTOR FROM :  http://www.java2s.com/Code/Jar/m/Downloadmysqlconnectorjar.htm

___________________________

INSERT RECORD IN JDBC - MYSQL EXAMPLE:

 try{

            Class.forName("com.mysql.jdbc.Driver");           

           Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/bca", "root", "");

           Statement st = (Statement) con.createStatement();

            int i=  st.executeUpdate("insert into register(uid,pass) values('avadh','tutor')");

           if(i>0)

           {

               System.out.println("Success");

           }

           else

           {

               System.out.println("Not Success");

           }

            

        }

        catch(Exception e)

        {

            System.out.println("Error"+e);

            

        }        


UPDATE RECORD INSIDE JDBC _ MYSQL:

  try {

            // TODO code application logic here

            //Update Record Using JDBC

            

            Class.forName("com.mysql.jdbc.Driver");

            Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/bca","root","");

            Statement st = (Statement)con.createStatement();

            int i = st.executeUpdate("update register set mobile='90987565' where uid='avadh'");

            if(i>0){

                System.out.println("Update Success");

                

            }

            else{

                 System.out.println("Not Success");

            }

        } catch (SQLException ex) {

            Logger.getLogger(UpdateRecord.class.getName()).log(Level.SEVERE, null, ex);

        }

        }


DELETE RECORD USING JDBC - MYSQL:

  try {

            // TODO code application logic here

            //Update Record Using JDBC

            

            Class.forName("com.mysql.jdbc.Driver");

            Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/bca","root","");

            Statement st = (Statement)con.createStatement();

            int i = st.executeUpdate("delete from register  where uid='avadh'");

            if(i>0){

                System.out.println("Delete  Success");

                

            }

            else{

                 System.out.println("Not Success");

            }

        } catch (SQLException ex) {

            Logger.getLogger(UpdateRecord.class.getName()).log(Level.SEVERE, null, ex);

        }

             

    }



How to Display Records inside JDBC MYSQL Example:

 try{       

        Class.forName("com.mysql.jdbc.Driver");

            java.sql.Connection con = (java.sql.Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/jdbc_connect","root","");

            Statement st = (Statement) con.createStatement();

           //ResultSet Query

            ResultSet rs =  st.executeQuery("select * from feedback  where id='"+i+"' ");

            while(rs.next())

            {

                String  id = String.valueOf(rs.getInt("id"));

                String name = String.valueOf(rs.getString("name"));

                String mobile = String.valueOf(rs.getString("mobile"));

                String email = String.valueOf(rs.getString("email"));                

                String tbdata[] = {id,name,mobile,email};

              //Add Table Data

                tbmodel.addRow(tbdata);

                        

            }

            

        }

        catch(Exception e)

        {

            

        }

       

    }  

  _____________________________

Advance java Tutorial Step by Step : https://youtube.com/playlist?list=PLkx9f4H3tJMI4735IyPUp88bKCvatY2IY


    

Sunday, 10 July 2022

JDBC - Java Database Connectivity

 


Learn Full Advacnce  Java Course
   https://youtube.com/playlist?list=PLkx9f4H3tJMI4735IyPUp88bKCvatY2IY

JAVA DATABASE CONNECTIVITY

Introduction of JDBC

JDBC is Java application programming interface that allows the Java programmers to access database management system from Java code.

JDBC stands for “Java Database Connectivity”. It is a java API which enables the java programs to execute SQL statements. It is an application programming interface that defines how a java programmer can access the database from Java code using a  set  of  standard  interfaces  and classes written in the Java programming language. The database that we want to connect must follow the ANSI SQL-2 standard.


JDBC Architecture

JDBC is a software abstraction sitting between your application and the database you want to access.

The application layer provides GUIs, business logic etc. and is written in Java.

JDBC layer  provides API calls to access different types of databases which the application layer   can use.


Database Drivers

JavaSoft develops the JDBC API. JavaSoft has divided JDBC driver into four categories, based on their  construction  and the type of database they are intended to support. To connect with individual databases, JDBC (the Java Database Connectivity API) requires drivers for each database. The JDBC driver gives out the connection to the database and implements the protocol for transferring the query and result between client and database.

These four categories are explained below.

§ Type 1: JDBC-ODBC Bridge Driver

§ Type 2: Native-API Driver

§ Type 3: Network Protocol Driver

§ Type 4: Native Protocol Driver


JDBC-ODBC Bridge Driver

The JDBC Type 1 driver is also known as the JDBC-ODBC Bridge. This driver is an implementation of the lower-level JDBC Driver API that makes use of the ODBC driver to connect to the database. The driver converts JDBC method calls into ODBC (Open Database Connectivity) calls and sends them to the ODBC driver. This implies that the ODBC driver, as well as the client database code, installed on the client machine.

The Type 1 Driver makes use of ODBC which in turn depends on native libraries of the underlying operating system which makes it platform-dependent. This makes any application that uses this driver non-portable as the ODBC driver for the specific operating system is required in the client machine. The database must also support the ODBC drivers for the Type 1 Driver to make a connection.

The bridge is usually used when there is no pure-Java driver available for a particular database.

Advantages

The following are the advantages of the Type 1 Driver:

§ Connectivity to most databases is possible as most databases contain ODBC drivers.

§ Installation of the Type 1 driver is very easy.

Disadvantages

The following are the disadvantages of the Type 1 Driver:

§ The Type 1 Driver is partially written in Java which makes it not portable.

§ The Type 1 Driver is not suitable for Internet Applications (Web Applications)

§ The Type 1 Driver contains a performance overhead as JDBC calls is converted into ODBC calls and then passed on to the ODBC driver.

Native-API Driver

The JDBC Type 2 driver is also known as the Native-API Driver. This driver is an implementation of the lower-level JDBC Driver API that makes use of the client-side libraries of the database to connect. The driver converts JDBC calls into database-specific calls on the client API for databases such as SQL Server, Informix, DB2, Oracle, or Sybase. The Type 2 driver communicates directly with the database server; therefore this style of driver requires that some binary code be loaded on each client machine.

Advantages

The following are the advantages of the Type 2 Driver:

§ The Type 2 Driver is better than the JDBC-ODBC bridge driver, since no ODBC  drivers  are  required.

Disadvantages

The following are the disadvantages of the Type 2 Driver:

§ The client API libraries of the specific database vendor must be installed on the client machine.

§ Not all the database vendors provide client API libraries.

§ The Type 2 Driver is not suitable for Internet Applications (Web Applications)


Network Protocol Driver

The JDBC Type 3 driver is also known as the Pure Java Driver for database Middleware. The JDBC Type 3 driver follows a three-tiered approach where the client code sends the JDBC calls through the network to a middle-tier server. The middle-tier converts the the JDBC calls directly or indirectly into database specific protocol, which will forward the JDBC calls to the database. The conversion logic that translates the JDBC calls resides in the middle-tier, and not in the client side like that of the JDBC Type 4 driver.

Advantages

The following are the advantages of the Type 3 Driver:

§ The translation of the JDBC calls resides on the middle-tier and therefore no database library is required on the client side.

§ On the client side only the JDBC Type 3 driver is required, and any database can be supported, as long as the middle-tier supports the database.

§ The middle-tier which implements the JDBC Type 3 driver can provide additional services like caching, auditing ...

Disadvantages

The following are the disadvantages of the Type 3 Driver:

§ The additional layer might be a bottleneck for the JDBC calls.

Native Protocol Driver

The JDBC Type 4 driver is also known as the Direct to Database Pure Java Driver. The JDBC Type  4 driver converts the JDBC calls directly into database specific calls which mean the client can directly communicate with the database management system (DBMS). The Type 4 drivers are completely written in Java and are therefore platform independent. The Type 4 driver is installed in client side and runs within the Java Virtual Machine.

Advantages

The following are the advantages of the Type 4 Driver:

§ The Type 4 driver is platform independent and therefore easy to deploy to different client environments.

§ The performance of Type 4 drivers is higher as the driver does not need to convert the JDBC calls into ODBC or to Middleware Type drivers.

Disadvantages

The following are the disadvantages of the Type 4 Driver:

§ A vendor-specific driver is required for each of the databases the client whishes to connect.




__________________________________________________

JDBC APIs for database Connectivity (Java.sql Package)




The JDBC 3.0 API includes the entire API in the java.sql package and the javax.sql package. The JDBC API is a Java API for accessing virtually any kind of tabular data. The JDBC API consists of    a set of classes and interfaces written in the Java programming language that provide a standard  API for tool/database developers and makes it possible to write industrial-strength database applications entirely in the Java programming language.

The JDBC API makes it easy to send SQL statements to relational database systems and supports  all dialects of SQL. But the JDBC API goes beyond SQL,

also making it possible to interact with other kinds of data sources, such as files containing tabular data.

In simplest terms, a JDBC technology-based driver ("JDBC driver") makes it possible to do three things:

1.     Establish a connection with a data source

2.    Send queries and update statements to the data source

3.    Process the results

In order to connect any application or an applet to a database there are various classes and interfaces are available in the java.sql package. Depending on the requirements these classes and interfaces can be used.

Some of the classes and interfaces which are used  to perform various database tasks.

java.sql.Connection

This interface abstracts most of the interaction with the database. In order to send SQL statements to the database and to read the results a connection is used. It is also used   to connect with the database.

java.sql.Driver

This is an interface that abstracts the vendor specific connection protocol. Implementations of this interface can

be found from database vendors as well as third party database driver vendors.

java.sql.DriverManager

This class provides the functionality necessary for managing one or more database drivers. Each driver in turn lets you to connect to a specific database.

java.sql.CallableStatement


This interface can be used to execute stored procedures.

java.sql.PreparedStatement

This is a variant of the java.sql.Statement interface allowing for parameterized SQL statements.

java.sql.ResultSet

This interface abstracts results of executing SQL SELECT statements. This interface provides methods to access the result row-by-row.

java.sql.statement

This interface lets you to execute SQL statements over the underlying connection and access the results.

Connection Interface

This interface is available in the java.sql package. The connection interface is used to establish a connection to the database you want to access. The Connection interface defines following  methods:

§ void close()

This method frees the Connection object’s database and other JDBC resources.

§    void commit()

This method makes all the changes made since the last commit or rollback permanent. It throws SQLException.

§ Statement createStatement()

This method creates a Statement object for sending SQL statements to the database. It throws SQLException.

§ Boolean isClosed()

This methods returns true if the connection is close else returns false.

§ CallableStatement prepareCall(String s)

This   method   creates   a   CallableStatement   object   for   calling  stored  procedures.                      It throws SQLException.

§ PreparedStatement prepareStatement(String s)

This method creates a PreparedStatement object for sending SQL statements with or without IN parameter. It throws SQLException.

§ void rollback()

This method undoes all changes made to the database.

Statement Interface

The Statement object is created for executing static SQL statements. To execute SQL Statements, Statement is the simple and easy.

The Statement interface has several methods which can be used to execute SQL statement.

§ void close()

This method releases the statement object’s database and JDBC resources.

§ boolean execute(String s)

This method executes the SQL statement specified by s.  The  getResultSet()  method  is  used  to  retrieve the result.

§ ResultSet executeQuery(String s)

This method executed the SQL statement specified by s and returns the ResultSet object.

§ int executeUpdate(String s)

This    method    executes    the    SQL    statement    specified    by    s.              These statements may be INSERT,UPDATE or DELETE.

§ int getMaxRows()

This method returns the maximum number of rows that  are  generated  by  the  executeQuery()  method.

§ ResultSet getResultSet()

This method retrives the ResultSet generated by the execute() method.

Prepared statement

The Prepared Statement object can be used to execute a dynamic SQL statement with IN  parameter. A Prepared Statement can be precompiled and used repeatedly. This interface has methods to handle PreparedStatement objects. The PreparedStatement object is created using PreparedStatement() method in Connection class.

§ Boolean execute()

This method executes the SQL statement in this object. The getResult() method is used to retrieve the result.

§ ResultSet executeQuery()

This method is used to execute SQL statements in this object. It returns the ResultSet object.

§ Int executeUpdate()

This method executes the SQL statement in this object. The SQL statement  must  be  an  SQL insert, update and delete statement.

§   ResultSetMetaData getMetaData()

This method retrieves a ResultSetMetaData object that contains information about the columns of the ResultSet object that will be returned when this object is executed.

§ IN Parameter:

§ An IN parameter is used to execute a dynamic SQL statement.


§  In some certain conditions where in we need to pass different values to an SQL  statement, then  such values can be specified by using ? in the SQL statement.

§ The actual values can be passed using the setXXX() method at the time of execution.

§ The “ ? “ in a Java SQL statement stands for an input parameter to be supplied after using setXXX method().

§ E.g.

PreparedStatement st = cnmain.prepareStatement(“Select * from emp where empno=?”); St.setInt(1,1002);

ResultSet rs= st.executeQuery();

S

The general form for setting the IN parameter is as : setXXX(integer, value)

Where xxx is the value type which may be int, float, Boolean etc... Integer is the position of IN parameter in the SQL statement. Value is the value that is to be supplied in place of ?.

Callable statement

§ A callable statement object is used to execute stored procedures defined in the RDBMS.

§ A procedure with OUT parameter can be executed only in this Callable Statement.

§ A callable statement can also contain IN parameter.

§ An OUT parameter has to be registered prior to executing the stored procedure.

§ An OUT parameter in the stored procedure is represented by (?).

§ An OUT parameter is  registered  using  the  registerOutParameter()  method.  This  method  declares what type of the OUT parameter is.

§ After the CallableStatement is executed, the OUT parameter are to be obtained using the getXXX() method.

§ The general form of registering OUT parameters other than NUMERIC and DECIMAL VALUES is as under :

registerOutParameter(int index, Type type)

where indx is the relative position of the OUT parameter in the SQL. Type is the SQL data type of OUT parameter.

§ E.g.

CallableStatement cstmt = con.prepareCall(EXECUTE ADD_REC(?,?,?));

There are three parameters. Let us assume that first two are IN parameters and the last one is the OUT parameter. The IN and OUT parameters are defined as under :

st.setInt(1,1001); st.setString(2,”Kamal”);

st.registerOutParameter(3,Types.LONGVARCHAR);

The CallableStatement is executed by calling the execute methods.

ResultSet rs = st.executeQuery();

The registered OUT parameter can be retrieved using getXXX() method in the CallableStatement interface.

§ BigDecimal getBigDecimal(int index)

This method retrieves the OUT parameters of JDBC NUMERIC type at the specified index.

§ byte getByte(int index)

This method retrieves the OUT parameter of JDBC NUMERIC type at the specified index location.

§ date getDate(int index)

This method retrieves the OUT parameter of JDBC DATE type at the specified index column.

§ double getDouble(int index)

This method retrieves the OUT parameter of JDBC DOUBLE type at the specified index column.

§ float getFloat(int index)

This method retrieves the OUT parameter of JDBC FLOAT type at the specified index column.

Result set

The executeQuery() and getResultSet() when called on Statement, PreparedStatement, and CallableStatement it returns the object of  type ResultSet. The ResultSet object contains results  after the execution of SQL statement. The ResultSet object maintains a cursor pointing to the current row of results. The next() method moves cursor to the next row of the result set. The ResultSet interface has many methods to get the results from the result set.

§ boolean absolute(int row)

This method moves the cursor to the specified row numer in the result set.

§ void afterLast()

This method moves the crsor to the end of the result set just after the last row.

§ void close()

This method releases the object’s database.

§ void deleteRow()

This method deletes the current row of this result set.

§ boolean first()

This method moves the cursor to the first row of the result set.

§ BigDecimal getBigDecimal(int index)

This method retrieves the value of the specified column as BigDecimal.

§ boolean getBoolean(int index)

This method retrieves the value of the specified column as Boolean.


§ boolean getBoolean(String clName)

This method retrieves the name of the specified column as Boolean.

§ byte getByte(int index)

This method retrieves the value of the specified column as byte.

§ date getDate(int index)

This method retrieves the value of the specified column as date.

§ float getFloat(int index)

This method retrieves the value of the specified column as float.

§ ResultSetMetaData getMetaData()

This method returns properties of the ResultSet object.

§ int getRow()

This method returns the current row number.

§ Statement getStatement()

This method returns the object which produced the ResultSet.

§ String getString(int index)

This method returns the object which produced the ResultSet.

§ boolean isFirst()

This method checks whether the cursor is in first row.

§ boolean isLast()

This method checks whether the cursor is in last row.

§ boolean next()

This method checks whether the cursor is in next row.

§ boolean previous()

This method checks whether the cursor is in previous row.



______________________________________________

Steps of JDBC URL for MS-Access database

1)       Go to Control Panel.

2)      Click on Administrative Tools.

3)      Click on Data Sources (ODBC).

4)      Select MS-Access database and then click on Add.

5)      Select Microsoft Access Driver (*.mdb).

6)      Click over the FINISH.

7)      It will display ODBC Microsoft Access Setup Dialog box.

8)      In this dialog box, type the name of the data source.

9)      Then click on Select in the Database frame.

10)   It will display "Select Database" dialog box.

11)    Select the database and click on the ok. ODBC data source is created.

__________________________________________________________

JDBC steps for ODBC Database Connection

Here are the basic steps to connect Java program to MySQL using JDBC APIs

1.      Importing required classes

Import java.sql package.

2.      Loading the Driver

In the second step of jdbc connection  process,  we  load  the  driver  by  calling  Class.forName()  method. A client can connect to Database server by JDBC driver

The call is made as given below: Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);

1.      Creating JDBC Connection to database

§ In order to create a connection, the loading of JDBC database driver does not connect to the database.

§ Before executing any SQL statement it is mandatory to establish a connection with a database.

§ To do this the getConnection() method of  the DriverManager  class is to be  invoked which is  used to  find a specific driver that can create a connection to the URL requested.

§ Here, the DriverManager class searches for the registered drivers which can process the database.

If a driver is not found then an exception is thrown.

§ The call to the getConnection() method is as given below.

Connection con = Drivermanager.getConnection(“jdbc:odbc:dbname”,“ ”, “ ” );

Here, the getConnection() method takes three arguments, the first is  the string   type argument  that      is the URL for the database. The second argument is username and the third  argument  is  the  password.

2.      Creating statement object

§ In order to interact with the database, the SQL statements must be executed.

§ This requires that a Statement object needs to be created to manage the SQL statements.

§ To do this the createStatement() method of the Connection class is to be invoked.

§ Statement st = con.createStatement();

§ The above statement creates a Statement object using the database connection.

§   The Statement class provides methods for executing SQL statements and retrieving the results   from the statements execution.


3.      Executing statement object

§ The SQL statement can be executed by invoking the executeQuery() method.

String query =”select * from emp”; ResultSet rs = st.executeQuery(query);

§ The above statement sends the query to the database and returns the results of the query as a ResultSet.

§ If there are any errors during the execution of the query then an exception is thrown.

4.      Manipulating ResultSet

§ The last step is to iterate the ResultSet.

§ A ResultSet is a collection of results retrieved from a query.

§ There are various methods available in the ResultSet class to iterate through these results.  One of  the method is next() which places the pointer to the next record. This method returns a Boolean value. If this value is true then it indicates that there is data to fetch.

§ A while loop can be used to fetch rows from a ResultSet.

§ rs.next() is used in the while loop for the iterating.

MS-Access Example

import java.sql.*; class select

{

public static void main(String args[])

{


try

{


 

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Connection con = DriverManager.getConnection("jdbc:odbc:student"); Statement st = con.createStatement();

String query = "select * from tblStudent"; ResultSet rs = st.executeQuery(query); while(rs.next())

{

                    //youtube.com/avadhtutor

int id = rs.getInt("id");

int rollno = rs.getInt("rollno"); String name = rs.getString("name");

String course = rs.getString("course");

 

System.out.println(id +" "+rollno +" "+name +" "+course);

}

}

catch(Exception e)

{

System.out.println(e);

}

}

}



___________________________________________________

JDBC steps for other Database Connection

1.      Load the JDBC driver

To load a driver, you specify the class name of the database driver in the Class.forName method.    By doing so, you automatically create a driver instance and register it with the JDBC driver manager.

try

{

Class.forName ("connect.microsoft.MicrosoftDriver"); Class.forName ("oracle.jdbc.driver.OracleDriver"); Class.forName ("com.sybase.jdbc.SybDriver");

Class.forName ("com.mysql.jdbc.Driver");

}

catch (ClassNotFoundException cnfe)

{

System.err.println ("Error loading driver: " + cnfe);

}

 

 

2.      Define the connection URL

In JDBC, a connection URL specifies the server host, port, and database name with which to establish a connection.

String host =  "localhost"; String dbName = "someName"; int port = 3306;

§ String oracleURL = "jdbc:oracle:thin:@" + host +":" + port + ":" + dbName;


§ String sybaseURL = "jdbc:sybase:Tds:" + host +":" + port + ":" + "?SERVICENAME=" + dbName;

§ String msAccessURL = "jdbc:odbc:" + dbName;

§ String mySqlURL = "jdbc:mysql://"+host+":"+port+"/"+dbName+"";

3.      Establish the connection

With the connection URL, username, and password, a network connection to the database can be established. Once the connection is established, database queries can be performed until the connection is closed.

String username = "root"; String password = "admin";

Connection connection =DriverManager.getConnection(mySqlURL, username, password);

4.      Create a Statement object

Creating a Statement object enables you to send queries and commands to the database. Statement statement = connection.createStatement();

5.      Execute a query or update

Given a Statement object, you can send SQL statements to the database by using the execute, executeQuery, executeUpdate.

String query = "SELECT col1, col2, col3 FROM sometable"; ResultSet resultSet = statement.executeQuery(query);

§ executeQuery

§   Executes an SQL query and returns the data in a ResultSet. The ResultSet may be empty, but    never null.

§ executeUpdate.

Used for UPDATE, INSERT, or DELETE commands. Returns the number  of  rows  affected,  which could be zero. Also provides support for Data Definition Language (DDL) commands, for example, CREATE TABLE, DROP TABLE, and ALTER TABLE.

6.      Process the results

When a database query is executed, a ResultSet is returned. The ResultSet represents a set of rows      and columns that you can process by calls  to  next  and  various  getXxx methods. while(resultSet.next())

{

System.out.println(resultSet.getString(1) + " " + resultSet.getString(2) + " " + resultSet.getString("firstname")    +    "     " resultSet.getString("lastname"));

}

We suggest that when you access the columns of a ResultSet, you use the column name instead of the column index. That way, if the column structure of the table changes, the code interacting with the ResultSet will be less likely to fail.

7.      Close the connection

When you are finished performing queries and processing results, you should close the connection, releasing resources to the database.

connection.close ();

Meta Data

The term "meta" here means information about your data that  does not interest the end users at  all, but which you need to know in order to handle the data. JDBC provides two meta-data classes: java.sql.ResultSetMetaData and java.sql.DatabaseMetaData. The meta-data described by these classes was included in the original JDBC ResultSet and Connection classes.

Result Set Meta Data

As its name implies, the ResultSetMetaData class provides extra information about ResultSet objects returned from a database query. In the embedded queries you made earlier in the book,    you hardcoded into your queries much of the information a ResultSetMetaData object gives you. This class provides you with answers to the following questions:

§ How many columns are in the result set?

§ Are column names case-sensitive?

§ Can you search on a given column?

§ Is NULL a valid value for a given column?

§ How many characters is the maximum display size for a given column?

§ What label should be used in a display header for the column?

§ What is the name of a given column?

§ What table did a given column come from?

§ What is the datatype of a given column?

Methods of Resultset Metadata:

§ getColumnCount()

Returns the number of columns in this ResultSet object.

§ getColumnName(int column)

Get the designated column’s name.


§ getColumnType(in column)

Retrieves the designated column’s SQL type.

§ getSchemaName(int column)

Get the designated column’s table’s schema.

§ getTableName(int column)

Get the designated column’s table name.

§ isAutoIncrement(int column)

Indicateds whether the designated column is automatically numbered, thus read-only.

§ isCaseSensitive(int column)

Indicates whether a column’s case matters.

§ isCurrency(int column)

Indicates whether the designated column is a cash value.

§ isNullable(int column)

Indicated the nullability of values in the designated column.

§ isReadonly(int column)

Indicates whether the designated column is definitely not writable.

Database Meta Data

As the ResultSetMetaData class relates to the ResultSet class, the DatabaseMetaData  class relates to the Connection class (in spite of the naming inconsistency). The DatabaseMetaData class provides methods that tell you about the database for a given Connection object, including:

§ What tables exist in the database visible to the user?

§ What username is being used by this connection?

§ Is this database connection read-only?

§ What keywords are used by the database that are not SQL2?

§ Does the database support column aliasing?

§ Are multiple result sets from a single execute () call supported?

§ Are outer joins supported?

§ What are the primary keys for a table?

Methods name:

§ getDatabaseProductName( )

Returns the product name. i.e. the name of the database program.

§ getDatabaseProdouctVersion( )

Returns the version of the database program.

§ getDriverName( )

Returns the type of the JDBC driver.

§ getUserName( )

Returns the current user name.

§ getCatalogs( )

Returns the name of the database file or database.




________________________________________________________________

JDBC Data Types

JDBC/Java

SQL

JDBC/Java

java.lang.String

DOUBLE

double

java.lang.String

VARBINARY

byte[ ]

java.lang.String

BINARY

byte[ ]

Boolean

DATE

java.sql.Date

java.math.BigDecimal

TIME

java.sql.Time

Byte

TIMESTAMP

java.sql.Timestamp

Short

CLOB

java.sql.Clob

Int

BLOB

java.sql.Blob

Long

ARRAY

java.sql.Array


________________________________________________________

Database Exception Handling

getErrorCode( )

Gets the error number associated with the exception.

 

getMessage( )

Gets the JDBC driver's error message for an error, handled by the driver or gets the Oracle error number and message for a database error.

 

 

getSQLState( )

Gets the XOPEN SQLstate string. For a JDBC driver error, no useful information is returned from this method. For a database error, the five-digit XOPEN SQLstate code is returned. This method can return null.

getNextException( )

Gets the next Exception object in the exception chain.






Learn Full Advacnce  Java Course
   https://youtube.com/playlist?list=PLkx9f4H3tJMI4735IyPUp88bKCvatY2IY