本文為大家介紹下使用jsp連接MySQL操作GIS地圖數據並實現添加point的功能
index_map
復制代碼 代碼如下:
<%@ page language="java" pageEncoding="utf
<%@ page contentType="text/html;charset=utf
<%
request
response
response
%>
insert_map
復制代碼 代碼如下:
<%@ page language="java" import="java
<%@ page contentType="text/html;charset=utf
<%
request
response
response
%>
<%
String id=request
String name=request
String voltage_level=request
String lon=request
String lat=request
java
String datetime=new Timestamp(date
try
{
/** 連接數據庫參數 **/
String driverName = "com
String DBUser = "root"; //mysql用戶名
String DBPasswd = "
String DBName = "map_db"; //數據庫名
String connUrl = "jdbc:mysql://localhost/" + DBName + "?user=" + DBUser + "&password=" + DBPasswd;
Class
Connection conn = DriverManager
Statement stmt = conn
stmt
String insert_sql = "INSERT INTO biandianzhan_point_tb VALUES(
String query_sql = "select * from biandianzhan_point_tb";
try {
stmt
}catch(Exception e) {
e
}
try {
ResultSet rs = stmt
while(rs
%>
ID
名稱
電壓等級
經緯度
<%
}
}catch(Exception e) {
e
}
//rs
stmt
conn
}catch (Exception e) {
e
}
%>
訪問index_map
提交前數據庫的值
輸入測試值並提交
數據庫的變化如下
可以看出
總的來說
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/20003.html