Windows 3.1 support for Berkeley DB can be found in the build_win16 directory.
This source has only been built using Watcom IDE 11.0 (under NT 4.0). Create a project, then add the .c files (not all of the clib or util files), and build a dll. You'll need to find the -I configuration, to add search locations for header files.
The "shared memory" support relies on the fact that the code will be in a dll, so static libraries will not work properly.