MySQL and PostgreSQL are free software, but you would still have to pay for a web hosting service to host both the web page(s) and the database engine and data. This is your most obvious path, as MySQL and PostgreSQL are available for very low cost web hosting and can easily scale if your site outgrows that first, low-cost, web hosting platform.
Oracle has a very limited free edition (11g Express Edition), but it isn't licensed for web server use. It limits to one CPU, 11GB of data, and one GB of RAM, so it will not scale to high-end services and will run quite slow. Plus, again, you'd need a server to install it on.
Oracle, Microsoft, Amazon, and others have cloud solutions, but these are not free either (Microsoft Azure, Oracle Cloud Services, Amazon's AWS).
The database hosts your data that is consumed by your application (J2EE, php, vb.net, etc., etc., etc.). So if you're developing a J2EE application, that gets packaged in a .JAR file that's presented at the application layer. The A in LAMP stack stands for Apache, an application/web server. Best practice is to separate your data from your application. Even if you used Oracle's built-in Java engine, you'd still have to build enough code at the application layer to connect to that Java code in your database, so why not do it all at the application layer? That's more robust -- if your system grows, you can move data to one or more database servers, and application to one or more app servers. And easier to migrate or maintain.