Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

How do you create Connection?

Answer Posted / vikky jain

i think the one of easiest way to create a connection is
that we have to perform following steps

1. we have to define what is driver name, url address of
database , user name and password of database .
like it

String driverName = "com.mysql.jdbc.Driver";
String url ="jdbc:mysql://localhost:3309/test";
String userid ="root";
String password ="1234";


after it we have to load drivers whatever name we given above
//driver loading
Class.forName(driverName);


after loading drivers we need to get the connection by using
this

con = DriverManager.getConnection(url, userid, password);

if value of con is not null then connection has been created
where con is an object of Connection class.
if the value is null it means that there may be some
trouble in database connectivity so it may throw an error
named SQLException

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do I find jdbc version?

949


Is it possible to connect to multiple databases simultaneously?

993


What is the use of JDBC DriverManager class?

1002


What are four types of JDBC driver?

1051


What class.forname will do while loading drivers of jdbc?

876


What is JDBC Transaction Management and why do we need it?

1037


Why hibernate is better than jdbc?

867


What causes the "No suitable driver" error?

967


What does executeupdate return in jdbc?

920


What is createstatement method in java?

907


What is jdbc odbc in java?

980


Why can't Tomcat find my Oracle JDBC drivers in classes111.zip?

914


What is savepoint in jdbc?

866


What is an encrypted internet connection?

877


What is the use of statement in jdbc?

870