dongxin991209 2011-06-11 17:02
浏览 23
已采纳

使用java与我服务器上的PHP脚本进行通信

I need to be able to access my database, which in it's own isn't hard as java can directly access it. I want to, however, use a php script to access it, as I need to insert stuff into the database as well, and I don't want to have the username and password of a read-write accoutn for my database in my java code. If someone decompiles it, he can just access my database and do stuff with it...

So basicly, I want to use a PHP script and send $_POST request info from my java code to my php script

(yes, java, not javascript ;-) )

  • 写回答

2条回答 默认 最新

  • dqqg0811 2011-06-11 17:32
    关注

    You can do this, no problem. Use a URLConnection with setDoOutput(true), and get its output stream for the POST.

    Of course, your PHP script should make sure that all data which is sent is sane, as anyone could send such a request to your PHP script. (Or you would need some way for the Java application to authenticate itself to the PHP script, which simply shifts the problem of hiding these credentials instead of the database ones.)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 WPF 大屏看板表格背景图片设置
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示