SlideShare a Scribd company logo
J2EE Database Connection
Lakhani Kamlesh J.
+91 95 86 331823
[1 | P a g e ]
Lakhani Kamlesh J.
Kamal.lakhani56@gmail.com
Lakhani Kamlesh J.
Kamal.lakhani56@gmail.com
+91 95 863 31823
Topic J2EE
CONNECTION
J2EE Database Connection
Lakhani Kamlesh J.
+91 95 86 331823
[2 | P a g e ]
Lakhani Kamlesh J.
Kamal.lakhani56@gmail.com
Connection (Type – 1)
Class.forName(“write”); Connecton con = DriverManagemer.getConnection(“write”);
1 Microsoft
Access
sun.jdbc.odbc.JdbcOdbcDriver Jdbc:odbc:DB Name
2 Oracle oracle.jdbc.driver.OracleDriver "jdbc:oracle:thin:127.0.0.1:DB Name",
"username", "password"
3 My SQL com.mysql.jdbc.Driver "jdbc:mysql://localhost/DB Name", "username",
"password"
4
5
6
7
Connection – (Type – Hibernate)
1 <property name="hibernate.dialect">org.hibernate.dialect.DerbyDialect</property>
<property
name="hibernate.connection.driver_class">org.apache.derby.jdbc.ClientDriver</property>
<property name="hibernate.connection.url">jdbc:derby://localhost:1527/sample</property>
<property name="hibernate.connection.username">app</property>
<property name="hibernate.connection.password">app</property>
Connection – (Type – JDBC 4.0)
1 String databaseURL = "jdbc:mysql://localhost:3306/test?user=root&password=root123";
Connection conn = null;
try
{
conn = DriverManager.getConnection(databaseURL);
if (conn != null)
{
System.out.println("Connected to the database");
}
}
catch (SQLException ex)
{
System.out.println("An error occurred. Maybe user/password is invalid");
ex.printStackTrace();
}
J2EE Database Connection
Lakhani Kamlesh J.
+91 95 86 331823
[3 | P a g e ]
Lakhani Kamlesh J.
Kamal.lakhani56@gmail.com
Connection – (Type – Properties)
1 String databaseURL = "jdbc:mysql://localhost:3306/test";
Properties props = new Properties();
props.put("user", "root");
props.put("password", "root123");
conn = DriverManager.getConnection(databaseURL, props);
Connection (Type – Derby)
Class.forName(“write”); Connecton con = DriverManagemer.getConnection(“write”);
1 Derby org.apache.derby.jdbc.ClientDriver "jdbc:derby://localhost:1527/DB Name (DB Path)
create=true; user=username; password=password"

More Related Content

What's hot

Entity Framework Database and Code First
Entity Framework Database and Code FirstEntity Framework Database and Code First
Entity Framework Database and Code First
James Johnson
 
Jdbc connectivity
Jdbc connectivityJdbc connectivity
Jdbc connectivity
arikazukito
 
Learn react.js with me!
Learn react.js with me!Learn react.js with me!
Learn react.js with me!
Shivani Thakur Daxini
 
Jdbc2016
Jdbc2016Jdbc2016
Java database connectivity with MySql
Java database connectivity with MySqlJava database connectivity with MySql
Java database connectivity with MySql
Dhyey Dattani
 
Jdbc
JdbcJdbc
Jdbc
Ishucs
 
Web 10mca556 syllabs
Web 10mca556 syllabsWeb 10mca556 syllabs
Web 10mca556 syllabs
Ramesh Bindu
 
Angular Data Binding
Angular Data BindingAngular Data Binding
Angular Data Binding
Jennifer Estrada
 
Office 365 busting the myths
Office 365 busting the mythsOffice 365 busting the myths
Office 365 busting the myths
Microsoft TechNet - Belgium and Luxembourg
 
ReactJS for Beginners
ReactJS for BeginnersReactJS for Beginners
ReactJS for Beginners
Oswald Campesato
 
MySQL Workbench Tutorial | Introduction To MySQL Workbench | MySQL DBA Traini...
MySQL Workbench Tutorial | Introduction To MySQL Workbench | MySQL DBA Traini...MySQL Workbench Tutorial | Introduction To MySQL Workbench | MySQL DBA Traini...
MySQL Workbench Tutorial | Introduction To MySQL Workbench | MySQL DBA Traini...
Edureka!
 
การพ ฒนาเว บไซต1
การพ ฒนาเว บไซต1การพ ฒนาเว บไซต1
การพ ฒนาเว บไซต1
Supawadee Sakun
 
การพัฒนาเว็บไซต์
การพัฒนาเว็บไซต์การพัฒนาเว็บไซต์
การพัฒนาเว็บไซต์
Nursary Devilz
 
การพ ฒนาเว บไซต1
การพ ฒนาเว บไซต1การพ ฒนาเว บไซต1
การพ ฒนาเว บไซต1
Supawadee Sakun
 
Better web apps with React and Redux
Better web apps with React and ReduxBetter web apps with React and Redux
Better web apps with React and Redux
Ali Sa'o
 
JDBC: java DataBase connectivity
JDBC: java DataBase connectivityJDBC: java DataBase connectivity
JDBC: java DataBase connectivity
Tanmoy Barman
 

What's hot (16)

Entity Framework Database and Code First
Entity Framework Database and Code FirstEntity Framework Database and Code First
Entity Framework Database and Code First
 
Jdbc connectivity
Jdbc connectivityJdbc connectivity
Jdbc connectivity
 
Learn react.js with me!
Learn react.js with me!Learn react.js with me!
Learn react.js with me!
 
Jdbc2016
Jdbc2016Jdbc2016
Jdbc2016
 
Java database connectivity with MySql
Java database connectivity with MySqlJava database connectivity with MySql
Java database connectivity with MySql
 
Jdbc
JdbcJdbc
Jdbc
 
Web 10mca556 syllabs
Web 10mca556 syllabsWeb 10mca556 syllabs
Web 10mca556 syllabs
 
Angular Data Binding
Angular Data BindingAngular Data Binding
Angular Data Binding
 
Office 365 busting the myths
Office 365 busting the mythsOffice 365 busting the myths
Office 365 busting the myths
 
ReactJS for Beginners
ReactJS for BeginnersReactJS for Beginners
ReactJS for Beginners
 
MySQL Workbench Tutorial | Introduction To MySQL Workbench | MySQL DBA Traini...
MySQL Workbench Tutorial | Introduction To MySQL Workbench | MySQL DBA Traini...MySQL Workbench Tutorial | Introduction To MySQL Workbench | MySQL DBA Traini...
MySQL Workbench Tutorial | Introduction To MySQL Workbench | MySQL DBA Traini...
 
การพ ฒนาเว บไซต1
การพ ฒนาเว บไซต1การพ ฒนาเว บไซต1
การพ ฒนาเว บไซต1
 
การพัฒนาเว็บไซต์
การพัฒนาเว็บไซต์การพัฒนาเว็บไซต์
การพัฒนาเว็บไซต์
 
การพ ฒนาเว บไซต1
การพ ฒนาเว บไซต1การพ ฒนาเว บไซต1
การพ ฒนาเว บไซต1
 
Better web apps with React and Redux
Better web apps with React and ReduxBetter web apps with React and Redux
Better web apps with React and Redux
 
JDBC: java DataBase connectivity
JDBC: java DataBase connectivityJDBC: java DataBase connectivity
JDBC: java DataBase connectivity
 

Similar to Connection Database

Jdbc ppt
Jdbc pptJdbc ppt
Jdbc ppt
sandeep54552
 
Chapter vii(accessing databases with jdbc)
Chapter vii(accessing databases with jdbc)Chapter vii(accessing databases with jdbc)
Chapter vii(accessing databases with jdbc)
Chhom Karath
 
SQL Bits: Containers and Clones
SQL Bits: Containers and ClonesSQL Bits: Containers and Clones
SQL Bits: Containers and Clones
Alex Yates
 
Mule esb – connecting to ms sql db
Mule esb – connecting to ms sql dbMule esb – connecting to ms sql db
Mule esb – connecting to ms sql db
Gunjan Deshmukh
 
jsp MySQL database connectivity
jsp MySQL database connectivityjsp MySQL database connectivity
jsp MySQL database connectivity
baabtra.com - No. 1 supplier of quality freshers
 
Jdbc drivers
Jdbc driversJdbc drivers
Jdbc drivers
Prabhat gangwar
 
Jdbc day-1
Jdbc day-1Jdbc day-1
Jdbc day-1
Soham Sengupta
 
Top 45 jQuery Interview Questions and Answers | Edureka
Top 45 jQuery Interview Questions and Answers | EdurekaTop 45 jQuery Interview Questions and Answers | Edureka
Top 45 jQuery Interview Questions and Answers | Edureka
Edureka!
 
JDBC Core Concept
JDBC Core ConceptJDBC Core Concept
JDBC Core Concept
Rays Technologies
 
Jdbc
JdbcJdbc
Jdbc
lathasiva
 
JDBC - JPA - Spring Data
JDBC - JPA - Spring DataJDBC - JPA - Spring Data
JDBC - JPA - Spring Data
Arturs Drozdovs
 
Different waysconnect
Different waysconnectDifferent waysconnect
Different waysconnect
myrajendra
 
J query
J queryJ query
High Performance Jdbc
High Performance JdbcHigh Performance Jdbc
High Performance Jdbc
Sam Pattsin
 
Java JDBC
Java JDBCJava JDBC
Jdbc
JdbcJdbc
4 jdbc step1
4 jdbc step14 jdbc step1
4 jdbc step1
myrajendra
 
Java database connectivity
Java database connectivityJava database connectivity
Java database connectivity
Atul Saurabh
 
Day2
Day2Day2
Jdbc
JdbcJdbc
Jdbc
Indu Lata
 

Similar to Connection Database (20)

Jdbc ppt
Jdbc pptJdbc ppt
Jdbc ppt
 
Chapter vii(accessing databases with jdbc)
Chapter vii(accessing databases with jdbc)Chapter vii(accessing databases with jdbc)
Chapter vii(accessing databases with jdbc)
 
SQL Bits: Containers and Clones
SQL Bits: Containers and ClonesSQL Bits: Containers and Clones
SQL Bits: Containers and Clones
 
Mule esb – connecting to ms sql db
Mule esb – connecting to ms sql dbMule esb – connecting to ms sql db
Mule esb – connecting to ms sql db
 
jsp MySQL database connectivity
jsp MySQL database connectivityjsp MySQL database connectivity
jsp MySQL database connectivity
 
Jdbc drivers
Jdbc driversJdbc drivers
Jdbc drivers
 
Jdbc day-1
Jdbc day-1Jdbc day-1
Jdbc day-1
 
Top 45 jQuery Interview Questions and Answers | Edureka
Top 45 jQuery Interview Questions and Answers | EdurekaTop 45 jQuery Interview Questions and Answers | Edureka
Top 45 jQuery Interview Questions and Answers | Edureka
 
JDBC Core Concept
JDBC Core ConceptJDBC Core Concept
JDBC Core Concept
 
Jdbc
JdbcJdbc
Jdbc
 
JDBC - JPA - Spring Data
JDBC - JPA - Spring DataJDBC - JPA - Spring Data
JDBC - JPA - Spring Data
 
Different waysconnect
Different waysconnectDifferent waysconnect
Different waysconnect
 
J query
J queryJ query
J query
 
High Performance Jdbc
High Performance JdbcHigh Performance Jdbc
High Performance Jdbc
 
Java JDBC
Java JDBCJava JDBC
Java JDBC
 
Jdbc
JdbcJdbc
Jdbc
 
4 jdbc step1
4 jdbc step14 jdbc step1
4 jdbc step1
 
Java database connectivity
Java database connectivityJava database connectivity
Java database connectivity
 
Day2
Day2Day2
Day2
 
Jdbc
JdbcJdbc
Jdbc
 

Recently uploaded

spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skillsspot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
haiqairshad
 
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
Nguyen Thanh Tu Collection
 
How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience
Wahiba Chair Training & Consulting
 
Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...
PsychoTech Services
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
math operations ued in python and all used
math operations ued in python and all usedmath operations ued in python and all used
math operations ued in python and all used
ssuser13ffe4
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
RAHUL
 
Bed Making ( Introduction, Purpose, Types, Articles, Scientific principles, N...
Bed Making ( Introduction, Purpose, Types, Articles, Scientific principles, N...Bed Making ( Introduction, Purpose, Types, Articles, Scientific principles, N...
Bed Making ( Introduction, Purpose, Types, Articles, Scientific principles, N...
Leena Ghag-Sakpal
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 
IGCSE Biology Chapter 14- Reproduction in Plants.pdf
IGCSE Biology Chapter 14- Reproduction in Plants.pdfIGCSE Biology Chapter 14- Reproduction in Plants.pdf
IGCSE Biology Chapter 14- Reproduction in Plants.pdf
Amin Marwan
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
TechSoup
 
Solutons Maths Escape Room Spatial .pptx
Solutons Maths Escape Room Spatial .pptxSolutons Maths Escape Room Spatial .pptx
Solutons Maths Escape Room Spatial .pptx
spdendr
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
Himanshu Rai
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 

Recently uploaded (20)

spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skillsspot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
 
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
 
How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience
 
Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
math operations ued in python and all used
math operations ued in python and all usedmath operations ued in python and all used
math operations ued in python and all used
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
 
Bed Making ( Introduction, Purpose, Types, Articles, Scientific principles, N...
Bed Making ( Introduction, Purpose, Types, Articles, Scientific principles, N...Bed Making ( Introduction, Purpose, Types, Articles, Scientific principles, N...
Bed Making ( Introduction, Purpose, Types, Articles, Scientific principles, N...
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 
IGCSE Biology Chapter 14- Reproduction in Plants.pdf
IGCSE Biology Chapter 14- Reproduction in Plants.pdfIGCSE Biology Chapter 14- Reproduction in Plants.pdf
IGCSE Biology Chapter 14- Reproduction in Plants.pdf
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
 
Solutons Maths Escape Room Spatial .pptx
Solutons Maths Escape Room Spatial .pptxSolutons Maths Escape Room Spatial .pptx
Solutons Maths Escape Room Spatial .pptx
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 

Connection Database

  • 1. J2EE Database Connection Lakhani Kamlesh J. +91 95 86 331823 [1 | P a g e ] Lakhani Kamlesh J. Kamal.lakhani56@gmail.com Lakhani Kamlesh J. Kamal.lakhani56@gmail.com +91 95 863 31823 Topic J2EE CONNECTION
  • 2. J2EE Database Connection Lakhani Kamlesh J. +91 95 86 331823 [2 | P a g e ] Lakhani Kamlesh J. Kamal.lakhani56@gmail.com Connection (Type – 1) Class.forName(“write”); Connecton con = DriverManagemer.getConnection(“write”); 1 Microsoft Access sun.jdbc.odbc.JdbcOdbcDriver Jdbc:odbc:DB Name 2 Oracle oracle.jdbc.driver.OracleDriver "jdbc:oracle:thin:127.0.0.1:DB Name", "username", "password" 3 My SQL com.mysql.jdbc.Driver "jdbc:mysql://localhost/DB Name", "username", "password" 4 5 6 7 Connection – (Type – Hibernate) 1 <property name="hibernate.dialect">org.hibernate.dialect.DerbyDialect</property> <property name="hibernate.connection.driver_class">org.apache.derby.jdbc.ClientDriver</property> <property name="hibernate.connection.url">jdbc:derby://localhost:1527/sample</property> <property name="hibernate.connection.username">app</property> <property name="hibernate.connection.password">app</property> Connection – (Type – JDBC 4.0) 1 String databaseURL = "jdbc:mysql://localhost:3306/test?user=root&password=root123"; Connection conn = null; try { conn = DriverManager.getConnection(databaseURL); if (conn != null) { System.out.println("Connected to the database"); } } catch (SQLException ex) { System.out.println("An error occurred. Maybe user/password is invalid"); ex.printStackTrace(); }
  • 3. J2EE Database Connection Lakhani Kamlesh J. +91 95 86 331823 [3 | P a g e ] Lakhani Kamlesh J. Kamal.lakhani56@gmail.com Connection – (Type – Properties) 1 String databaseURL = "jdbc:mysql://localhost:3306/test"; Properties props = new Properties(); props.put("user", "root"); props.put("password", "root123"); conn = DriverManager.getConnection(databaseURL, props); Connection (Type – Derby) Class.forName(“write”); Connecton con = DriverManagemer.getConnection(“write”); 1 Derby org.apache.derby.jdbc.ClientDriver "jdbc:derby://localhost:1527/DB Name (DB Path) create=true; user=username; password=password"