Standard C++ does not have any database code. Depend on which database, you try to get individual database-specific C++ libraries to communicate with database. For Oracle, it is Pro*C/C++ or Oracle OCI. For other database there will be something equivalent.
Java built one more abstraction layer so all we need is to get the individual database provided jdbc driver. Then your code write one time can 'talk' to different database via those jdbc drivers. This is one good JDBC API Java has over C++.
Well in general a "database" is just some file containing data, depending on its type this data is stored differently. In general yes its easy to use databases, that's what programs do - manipulating data... if you're using commercial progs to create the database, you'll need to find out how they're structured to read them correctly, which might be a pain. If you just read plain text or such its easy.
I really can't answer your question "what is the code..." since I have no idea what you want to do and where your problem actually is. Try it and come back with some question!