62,634
社区成员




create table url(www varchar(100));
insert into url values('http://hq.sinajs.cn/list=')
create table product(code varchar(10),name nvarchar(20));
insert into product values('sh601006','大秦铁路');
insert into product values('sh601001','大同煤业');
create view v_link
as
select b.www,a.code from product as a cross join url as b
create table quotdata(
ContractId INT(11),
RisePrice decimal(20,8),
FallPrice decimal(20,8),
OpenPrice decimal(20,8),
NewPrice decimal(20,8),
package andyu;
import java.sql.*;
public class connSqlServer {
public static void main(String[] srg) {
connSqlServer cServer=new connSqlServer();
}
public connSqlServer()
{
String driverName = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; //加载JDBC驱动
String dbURL = "jdbc:sqlserver://localhost:1433; DatabaseName=SinaQuot"; //连接服务器和数据库test
String userName = "sa"; //默认用户名
String userPwd = "123456"; //密码
@SuppressWarnings("unused")
Connection dbConn;
try {
Class.forName(driverName);
dbConn = DriverManager.getConnection(dbURL, userName, userPwd);
System.out.println("Connection Successful!"); //如果连接成功 控制台输出Connection Successful!
Statement s=dbConn.createStatement();
String selectsql ="select * from v_link";
ResultSet r=s.executeQuery(selectsql);
while(r.next())
{
System.out.print(r.getString("www")+r.getString("code")+"\n");
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
public class TStQuote {
private String advstop = "--";
private String amount = "--";
private String avgvolume = "--";
private List buyprice = null;
private List buyvolume = null;
private String decstop = "--";
private String high = "--";
private String inner = "--";
private String lastclose = "--";
private String low = "--";
private String newprice = "--";
private String nowvol = "--";
private String obj = "--";
private String open = "--";
private String outter = "--";
private List sellprice = null;
private List sellvolume = null;
private String settleprice = "--";
private String tickcount = "--";
private String time = "--";
private String volume = "--";
public TStQuote() {
}
public TStQuote(String advstop, String amount, String avgvolume,
List buyprice, List buyvolume, String decstop, String high,
String inner, String lastclose, String low, String newprice,
String nowvol, String obj, String open, String outter,
List sellprice, List sellvolume, String settleprice,
String tickcount, String time, String volume) {
super();
this.advstop = "".equals(advstop) ? "--" : advstop;
this.amount = "".equals(amount) ? "--" : amount;
this.avgvolume = "".equals(avgvolume) ? "--" : avgvolume;
this.buyprice = buyprice;
this.buyvolume = buyvolume;
this.decstop = "".equals(decstop) ? "--" : decstop;
this.high = "".equals(high) ? "--" : high;
this.inner = "".equals(inner) ? "--" : inner;
this.lastclose = "".equals(lastclose) ? "--" : lastclose;
this.low = "".equals(low) ? "--" : low;
this.newprice = "".equals(newprice) ? "--" : newprice;
this.nowvol = "".equals(nowvol) ? "--" : nowvol;
this.obj = "".equals(obj) ? "--" : obj;
this.open = "".equals(open) ? "--" : open;
this.outter = "".equals(outter) ? "--" : outter;
this.sellprice = sellprice;
this.sellvolume = sellvolume;
this.settleprice = settleprice;
this.tickcount = "".equals(tickcount) ? "--" : tickcount;
this.time = "".equals(time)?new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) : time;
this.volume = "".equals(volume) ? "--" : volume;
}
public String getAdvstop() {
return advstop;
}
public void setAdvstop(String advstop) {
this.advstop = advstop;
}
public String getAmount() {
return amount;
}
public void setAmount(String amount) {
this.amount = amount;
}
public String getAvgvolume() {
return avgvolume;
}
public void setAvgvolume(String avgvolume) {
this.avgvolume = avgvolume;
}
public List getBuyprice() {
return buyprice;
}
public void setBuyprice(List buyprice) {
this.buyprice = buyprice;
}
public List getBuyvolume() {
return buyvolume;
}
public void setBuyvolume(List buyvolume) {
this.buyvolume = buyvolume;
}
public String getDecstop() {
return decstop;
}
public void setDecstop(String decstop) {
this.decstop = decstop;
}
public String getHigh() {
return high;
}
public void setHigh(String high) {
this.high = high;
}
public String getInner() {
return inner;
}
public void setInner(String inner) {
this.inner = inner;
}
public String getLastclose() {
return lastclose;
}
public void setLastclose(String lastclose) {
this.lastclose = lastclose;
}
public String getLow() {
return low;
}
public void setLow(String low) {
this.low = low;
}
public String getNewprice() {
return newprice;
}
public void setNewprice(String newprice) {
this.newprice = newprice;
}
public String getNowvol() {
return nowvol;
}
public void setNowvol(String nowvol) {
this.nowvol = nowvol;
}
public String getObj() {
return obj;
}
public void setObj(String obj) {
this.obj = obj;
}
public String getOpen() {
return open;
}
public void setOpen(String open) {
this.open = open;
}
public String getOutter() {
return outter;
}
public void setOutter(String outter) {
this.outter = outter;
}
public List getSellprice() {
return sellprice;
}
public void setSellprice(List sellprice) {
this.sellprice = sellprice;
}
public List getSellvolume() {
return sellvolume;
}
public void setSellvolume(List sellvolume) {
this.sellvolume = sellvolume;
}
public String getSettleprice() {
return settleprice;
}
public void setSettleprice(String settleprice) {
this.settleprice = settleprice;
}
public String getTickcount() {
return tickcount;
}
public void setTickcount(String tickcount) {
this.tickcount = tickcount;
}
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
public String getVolume() {
return volume;
}
public void setVolume(String volume) {
this.volume = volume;
}
@Override
public String toString() {
return "TStQuote [advstop=" + advstop + ", amount=" + amount
+ ", avgvolume=" + avgvolume + ", buyprice=" + buyprice
+ ", buyvolume=" + buyvolume + ", decstop=" + decstop
+ ", high=" + high + ", inner=" + inner + ", lastclose="
+ lastclose + ", low=" + low + ", newprice=" + newprice
+ ", nowvol=" + nowvol + ", obj=" + obj + ", open=" + open
+ ", outter=" + outter + ", sellprice=" + sellprice
+ ", sellvolume=" + sellvolume + ", settleprice=" + settleprice
+ ", tickcount=" + tickcount + ", time=" + time + ", volume="
+ volume + "]";
}
}
var hq_str_sh601006="大秦铁路,7.08,7.08,7.06,7.08,7.05,7.05,7.06,2013907,14229810,795171,7.05,232900,7.04,304700,7.03,373200,7.02,90500,7.01,82594,7.06,156208,7.07,98740,7.08,35900,7.09,107400,7.10,2013-06-04,09:51:30,00";
新浪这样做就是不想别人看他行情的具体属性。哈哈package andyu;
import java.io.BufferedReader;
import java.io.BufferedWriter;
//import java.io.File;
//import java.io.FileReader;
//import java.io.FileWriter;
//import java.io.IOException;
//import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
//import java.util.ArrayList;
//import java.util.Arrays;
//import java.util.List;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.sql.*;
public class SinaQuot1 {
//PreparedStatement ps=null;
//Connection ct=null;
//ResultSet rs=null;
String driverName = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; //加载JDBC驱动
String dbURL = "jdbc:sqlserver://localhost:1433; DatabaseName=SinaQuot"; //连接服务器和数据库test
String userName = "sa"; //默认用户名
String userPwd = "123!@#qweQWE"; //密码
Connection dbConn;
String text=null;
StringBuffer sb=new StringBuffer();
public static void main(String args[]){
SinaQuot1 sq1=new SinaQuot1();
}
public SinaQuot1()
{
try{Class.forName(driverName);
dbConn = DriverManager.getConnection(dbURL, userName, userPwd);
System.out.println("Connection Successful!"); //如果连接成功 控制台输出Connection Successful!
Statement s=dbConn.createStatement();
String selectsql ="select * from v_link";
ResultSet r=s.executeQuery(selectsql);
StringBuffer sb=new StringBuffer();
try {
URL readSource = new URL("http://hq.sinajs.cn/list=sh601001");
BufferedReader input = new BufferedReader(new InputStreamReader(readSource.openStream()));
String line;
while((line = input.readLine()) !=null){
sb.append(line);
}
System.out.println(sb.toString());
} catch (Exception e) {
e.printStackTrace();
}
while(r.next())
{
text=r.getString("www")+r.getString("code");
System.out.print(text+"\n");
}
}catch(Exception e) {
e.printStackTrace();
}finally{
}
}
}
我暂时还只会到这里 获取字符