How do you create Connection?

Answers were Sorted based on User's Feedback



How do you create Connection?..

Answer / p.kodanda rami reddy

After loading the driver in order to refer the what kind of
database u communicate we Establish the connection with the
help of a static method called GETCONNECTION this is from
DRIVER MAMAGER.GETCONNECTION. accepting arguments as JDBC
URL ,USER NAME , PASSWORD
EX: DriverManager.getConnection
("jdbc:odbc:sid","scott","tiger");
here jdbc,odbc,sid -> is url and sid is service id.
scott - > is user name.
tiger - > is password.

Is This Answer Correct ?    3 Yes 0 No

How do you create Connection?..

Answer / mathivanan

Connection is the second step of JDBC followed by
Driver_Loading. It gives the connection between the
database Driver's Manager and our java program.

Syntax: Connection con_obj = DriverManager.getConnection
("url", "login_name", "password");

Is This Answer Correct ?    3 Yes 0 No

How do you create Connection?..

Answer / suresh kumar

to create connection first we have to load the driver using
class.forName(drivername)
then register the driver using DriverManager.getConnection()
afterwards you can create Statement object and u can
execute the qurey

Is This Answer Correct ?    1 Yes 0 No

How do you create Connection?..

Answer / 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

How do you create Connection?..

Answer / ramu

. To create connection first we have to load the driver using
class.forName(drivername)
. Get a connection to the database using DriverManager.getConnection()
after wards you can create Statement object and u can
execute the query

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More JDBC Interview Questions

What type of drivers have you used?

1 Answers  


How to connect multiple database in jdbc?

0 Answers  


How can we move the cursor in a scrollable result set?

0 Answers  


What is the role of the jdbc drivermanager class?

0 Answers  


Does the JDBC-ODBC Bridge support multiple concurrent open statements per connection?

0 Answers  






code to insert values/rows into oracle database from a java swing textfield when a button is pressed(using preparedstatements)

0 Answers  


Hi friends, In JDBC 4 drivers are there among this which driver is best and why it is best.Which driver is most commonly used in web applications.

6 Answers  


What are jdbc?

0 Answers  


what is callable statement?

6 Answers   Infogain,


What are the steps to connect to the database in java?

0 Answers  


How data can be inserted into long row column of database?

0 Answers  


What is the use of prepared statement?Ans:used to execute pre compiled statement...so the question is when that precompiled statement will be execute or comiple?................

6 Answers   TCS,


Categories