When is a connection established with the DB?

-1

I am learning a bit about JDBC and MySQL and I had a question when connecting to the database, and it is knowing at what moment the connection to it is "opened".

  • When is the Connection object instantiated?.

      

    Connection with = DriverManager.getConnection (.......);

  • When is a statement created with the Connection object?.

      

    PreparedStatment ps = con.PrepareStatement (........);

  • When the PreparedStatment is running?.

      

    ps.executeUpdate () or ps.executeQuery ()?

Thanks

    
asked by FrancoNNF 09.10.2018 в 23:46
source

2 answers

1

What I understand is the connection when you create the Connetion object by calling the DriverManager.getConnection (...) method;

Connection con = DriverManager.getConnection(...);

I recommend reading the java API here Class DriverManager and something else .

    
answered by 10.10.2018 в 06:51
0

It would be when you call the connector or driver that allows you to connect to the database here is where you connect to the database.

When is the Connection object instantiated? Connection with = DriverManager.getConnection (.......);

    
answered by 10.10.2018 в 07:13