atracks.java
来自「基于Java的地图数据管理软件。使用MySQL数据库管理系统。」· Java 代码 · 共 75 行
JAVA
75 行
package net.aetherial.gis.database;
import java.util.*;
import java.sql.*;
import net.aetherial.gis.excel.*;
public class ATracks
extends ConnectTracks {
public String tracksName = "";
public Vector name = new Vector(), lat = new Vector(), lon = new Vector();
public ATracks() {
super();
}
public void getTracks(int tracksID) { //取出一条航迹
ResultSet rs = null;
name = null;
lat = null;
lon = null;
String a,b,c;
/////////////////////////取出航迹名称//////////////////////////////////
this.sqlString = "Select * From tracksName Where ID =" + tracksID;
try {
rs = this.sql.executeQuery(sqlString);
if (rs.next()) {
tracksName = rs.getString("name");
}
}
catch (Exception e) {
e.printStackTrace();
}
/////////////////////////取出航迹名称——结束//////////////////////////////////
/////////////////////////取出航迹的各个点////////////////////////////
rs = null;
this.sqlString = "Select * From tracks Where track_ID =" + tracksID;
try {
rs = this.sql.executeQuery(sqlString);
while (rs.next()) {
a=rs.getString("name");
b=rs.getString("lat");
c=rs.getString("lon");
name.addElement(a);
lat.addElement(b);
lon.addElement(c);
}
}
catch (Exception e) {
e.printStackTrace();
}
//////////////////////////取出航迹的各个点——结束///////////////////////////
this.setClose();
}
public static void main(String args[]) {
ATracks at = new ATracks();
at.getTracks(2);
String[] number = new String[at.name.size()],
name = new String[at.name.size()], lat = new String[at.name.size()],
lon = new String[at.name.size()];
for (int i = 0; i < name.length; i++) {
number[i] = i + "";
name[i] = at.name.get(i) + "";
lat[i] = at.lat.get(i) + "";
lon[i] = at.lon.get(i) + "";
}
try{
CopyEditExcel t = new CopyEditExcel("D:\\GIS\\Excel\\test.xls");
t.fileCreate(at.tracksName, number, name, lat, lon, "", "", "", "", "",
"", "", "", "", "", "");
}catch(Exception e){
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?