Writing a MYSQL backed Java Back end Service for Dummies
So I want to do the simplest possible thing.
Assume I have a MYSQL enabled hosting service.
In it, I have a database storyland
and a table story-->(id, title, text)
I only know how to write Java programs in eclipse that run on my computer and do homework assignments well...:)
Now I want to
1) write a Java program that is hosted on my server that would compute and return (for exampl开发者_运维技巧e) the number of characters of text stored in the entire MYSQL database
Then I also only have experience with writing PHP programs that talk directly to MYSQL via forms e.t.c but now i want to
2) be able to display a page index.php that says
echo "Welcome to storyland, there are $textcount
characters of text in all stories here";
where $textcount
is the number returned by the java service.
I would appreciate really specific answers for this really "simple" specific example..to get me started. I'd also appreciate answers/resources that do not lean too heavily on external libraries/software since i want to be able to understand how those libraries work to be able to decide how to use them in future.
Thanks!
A design thought: I'd be tempted to have one more column - size, and have that precomputed for each blob of text, so you wouldn't have to calculate that (which might be expensive to count a blob > varchar size). Then I'd just issue a SUM over that column and be done: SELECT SUM(size) from mytable;
That would make the db work real simple, a simple INSERT and SELECT system really.
You need to have your own server, or a server that supports java, else this is not possible.
Even if you have a server that supports java, why do this with java when you can do it with php, the bottleneck will probably be the database anyhow.
精彩评论