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 resultset?

1004


What is getconnection method in java?

944


I have the choice of manipulating database data using a byte[] or a java.sql.blob. Which has best performance?

939


What is savepoint in jdbc?

919


Is there another way of dealing with the result set that could execute faster?

1010


What is the latest version of JDBC? What are the new features added in that?

1001


What is JDBC Connection? Explain steps to get Database connection in a simple java program.

1186


What does the jdbc resultset interface?

980


What are the different types of lockings in jdbc?

929


What is jdbc class forname?

970


How do I receive a ResultSet from a stored procedure?

975


What is Apache DBCP API?

1021


What is jdbc template?

970


How to check jdbc connection in java?

938


What is db client?

988