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

What is java soft framework?

975


How many types of statements are there in jdbc?

915


What is the limitation of PreparedStatement and how to overcome it?

1131


Explain the locking system in jdbc?

924


What are types of resultset?

973


What is @entity in java?

936


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

920


What packages are used by jdbc?

932


List some new features available in jdbc 4.0?

893


What are the different types of statements? How we can you use preparedstatement.

949


Explain in detail about JDBC and its general features?

941


What is jdbc connection class?

881


Explain about the Try Block?

965


Where is jdbc url mysql?

967


What do you mean by batch processing in jdbc?

1001