您好,欢迎访问一九零五行业门户网

获取mysql内容,生成xml文件,并且以webservice形式发送_MySQL



其实是三个知识点综合到一起的,包括如何访问mysql,如何生成xml文件,如何使用进行webservice开发好了,话不多说,直接粘代码
package com.service;import java.io.fileoutputstream;import java.io.ioexception;import java.sql.*;import org.jdom.*;import org.jdom.output.xmloutputter;public class newsimpl implements newsinterface{ public string getnews(int startpage, int endpage) { // 创建根节点 list; element root = new element(xyt); // 根节点添加到文档中; document doc = new document(root); connection conn = null; statement stmt = null ; // 此处 for 循环可替换成 遍历 数据库表的结果集操作; try { class.forname(org.gjt.mm.mysql.driver).newinstance(); string url_connect =jdbc:mysql://localhost/nxu_life?user=root&password=12345&useunicode=true&characterencoding=gb2312; //first为你的数据库名 try { conn = drivermanager.getconnection(url_connect); } catch (sqlexception e0) { // todo auto-generated catch block e0.printstacktrace(); } try { stmt = conn.createstatement(resultset.type_scroll_sensitive,resultset.concur_updatable); } catch (sqlexception e00) { // todo auto-generated catch block e00.printstacktrace(); } string sql=select page_id,title,url,publishtime,page,department from news where page_id>=+startpage+ and page_id
其它类似信息

推荐信息