import java.io.*;
import java.net.*;
/**
* 獲取一個(gè)網(wǎng)頁(yè)的源代碼
* @author Tony
*/
public class GetCode {
//方法:獲取網(wǎng)頁(yè)的源代碼 //打印出得到的網(wǎng)頁(yè)代碼 }
public static String getNetcode(String spec)
{
String line = null;
String temp = null;
try{
URL url=new URL(spec); //設(shè)置URL
HttpURLConnection uc = (HttpURLConnection)url.openConnection();//打開(kāi)連接
//獲取到輸入流
BufferedReader in=new BufferedReader(new InputStreamReader(uc.getInputStream()));
while((line=in.readLine())!=null)
{
temp+=line;//向temp里添加網(wǎng)頁(yè)代碼
}
if(in!=null)
in.close();
}
catch(Exception e)
{
e.printStackTrace();
}
return temp;
}
/**
* @param args
*/
public static void main(String[] args) {
String bookName = "傻B巴西的卡卡";//最初要搜尋的漫畫名稱
String category = "漫畫"; //類型
String sendName; //實(shí)際發(fā)送的漫畫名稱關(guān)鍵字
String url = null;//發(fā)送去的url地址
try
{
sendName = URLEncoder.encode(bookName,"gb2312");
//實(shí)際發(fā)送的漫畫類型
String sendCategory = URLEncoder.encode(category,"gb2312");
//整合url 并帶上查詢關(guān)鍵子、類型
url = new String("
System.out.println(getNetcode(url));
}
catch(Exception e)
{
e.printStackTrace();
}
}
代碼如上。這個(gè)代碼對(duì)于baidu首頁(yè)的源代碼能夠正常獲取到,但對(duì)baidu顯示查詢結(jié)果頁(yè)面卻不能獲取到,報(bào)錯(cuò)為:Unexpected end of file from server 請(qǐng)問(wèn)為什么呢?有什么解決方法嗎?
??? 今天好好的把Struts重新復(fù)習(xí)了遍,然后做了一個(gè)小程序,這個(gè)程序涉及到AJAX,struts,bean標(biāo)簽
的一些技術(shù)。AJAX的運(yùn)用今天也算基本上掌握了,這也真是一個(gè)不錯(cuò)的技術(shù),對(duì)程序的負(fù)重也不大,值得
以后深入的研究。 剛接觸struts這個(gè)MVC框架不久,感覺(jué)這個(gè)框架呢基本上是用配置文件省略去許多的
工作,想起上個(gè)月那個(gè)web項(xiàng)目,哇,Struts的確能讓編碼輕松不少,減少冗余代碼。而關(guān)于bean標(biāo)簽,
確實(shí)比較頭疼,我最薄弱的地方就是涉及到HTML XML 的一些東西,頭疼啊,而且要結(jié)合struts AJAX,
哎,弄的我差點(diǎn)土血,還好最終的結(jié)果是弄明白了,不過(guò)真是。。。-_-!
?? 昨天重新裝了系統(tǒng),結(jié)果今天就中病毒了,在Eclipse上無(wú)法編碼(根本點(diǎn)不出東西來(lái)),期盼明天有
了殺毒軟件后能夠恢復(fù)正常的工作。。。 老天保佑~~!!
??? 今天在深入學(xué)習(xí)了數(shù)據(jù)庫(kù)方面的知識(shí)。感覺(jué)挺吃力。 今天發(fā)現(xiàn)很多理論的知識(shí)掌握很不牢固,真是很慚愧,今后還得繼續(xù)在理論上下工夫。再說(shuō)今天接觸的知識(shí)吧,今天老總深入講解了關(guān)于select查詢方法的使用,發(fā)現(xiàn)這個(gè)東西實(shí)在是太靈活了!目前的自己拿著一個(gè)小項(xiàng)目也無(wú)法找到下手的方向,這應(yīng)該就是極度缺乏經(jīng)驗(yàn)的表現(xiàn),今后還得多多練習(xí)才能有顯著的提高。關(guān)于select,我先是很無(wú)語(yǔ),確實(shí)是非常的靈活,就其中的連接一項(xiàng),就嗆得我要死,看來(lái)自己在這幾天還得多多看相關(guān)的資料多多做練習(xí)才行。希望在研究數(shù)據(jù)庫(kù)的同志們也加油,多看書,多看看好的代碼,多去理解,這樣自己才能有提高。 最后,把今天在老總帶領(lǐng)下完成的關(guān)于電子書店數(shù)據(jù)庫(kù)系統(tǒng)的代碼放在這里,對(duì)于老手來(lái)說(shuō)非常的簡(jiǎn)單,望所有新手共勉!
(該代碼沒(méi)有涉及insert into,其中數(shù)據(jù)可以根據(jù)實(shí)際情況添加)
create table customers
(customerID int primary key not null,
customername varchar(20) not null);?
create table books
(bookid int primary key not null,
booktitle varchar(50) not null,
unitprice int not null
);?
create table orders
(orderid int primary key not null,
orderdate date default sysdate not null,
customerid int not null,
constraint fk_c foreign key (customerid) references customers(customerid)
);?
create table orderitems
(OrderItemID int primary key not null,
orderid int not null,
bookid int not null,
quantity int default '1' not null,
constraint fk_b foreign key (bookid) references books(bookid), constraint fk_o? foreign key (orderid) references orders(orderid));?
select c.customername as 客戶名稱, sum(b.unitprice * oi.quantity)
from customers c
left join orders o on c.customerid = o.customerid
left join orderitems oi on o.orderid = oi.orderid
left join books b on oi.bookid = b.bookid
where to_char(o.orderdate,'yyyy') = to_char(sysdate,'yyyy')
group by c.customername
?? ? 近來(lái)開(kāi)始學(xué)習(xí)數(shù)據(jù)庫(kù),剛開(kāi)始感覺(jué)挺無(wú)聊的,而且有點(diǎn)難,但經(jīng)過(guò)一些
鉆研后發(fā)現(xiàn)其實(shí)也不是想象中的那么難,關(guān)鍵是要把基本的語(yǔ)法掌握扎
實(shí),進(jìn)而才能靈活的應(yīng)用。? 最讓我無(wú)語(yǔ)的就是安裝Oracle花費(fèi)了我大量的
時(shí)間,哎,真的是非常的慚愧。 從小星期一開(kāi)始就要進(jìn)入深入的研究階
段,希望自己能有個(gè)比較 突出的飛躍吧,最后在JAVA網(wǎng)站制作項(xiàng)目中能
發(fā)揮好點(diǎn)吧。