0% found this document useful (0 votes)
2 views7 pages

Java Database Connection Guide

The document discusses how to connect a Java application to a MySQL database. It provides steps for setting up the database connection, creating a database and table, connecting the Java project to the database, querying the database, and inserting records into the database table.

Uploaded by

itsfake
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views7 pages

Java Database Connection Guide

The document discusses how to connect a Java application to a MySQL database. It provides steps for setting up the database connection, creating a database and table, connecting the Java project to the database, querying the database, and inserting records into the database table.

Uploaded by

itsfake
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Database Connection

with Java
SOFTWARE ENGINEERING
Requirements

 Java Complier (Eclipse)


 Database Management System (MySQL)
 SQL Connector Jar File
[Link]

 Download File
 [Link]
 Go to C/ProgramFiles/Java/JRE/Lib/Ext
 Paste SQL Connector File.
Create Database

 Create Database with a meaningful name


 Create Table Login
 Create 3 attributes (id , name, password)
Create Project and Connect DB
 Create Java Project and Add a Jframe with Absolute Layout
 Make an interface for login
 Go to event handler of Login Button
 Write [Link](“[Link]”)
 Create a Connection Object
 Connection Con = [Link](Host,UserName,Password)
 Create a Statement Object
 Statement St = [Link]();
 Write a Query “Select *From Table where………”
Cont…
 Create a ResultSet Object
 ResultSet RS = [Link](Query)
 If([Link]){
 Code…..
 }
Inserting Record
 Same as Previous Create Connection
 Get the Values from TextBoxes and Store in String Variables
 Write a Query “Inser INTO Table(Attributes) Values(?,?)
 Create a PreparedStatement Object
 PreparedStatement PR = [Link](Query);
 Set the Strings or Int of PR
 [Link](index,value) , PRsetInt(index,value)
 [Link]()

You might also like