无法在eclipse中测试我的数据库连接

时间:2018-03-04 10:58:18

标签: java database eclipse jdbc

惠  我似乎无法为我的项目连接数据库,我无法弄清楚为什么。我已经在Mysql工作台中创建了数据库,但仍然无法运行jdbc.java

import csv
import urllib.request
from bs4 import BeautifulSoup


write_header = True

twiturl = "https://twitter.com/ACInvestorBlog"
twitpage = urllib.request.urlopen(twiturl)
soup = BeautifulSoup(twitpage,"html.parser")

print(soup.title.text)

tweets = [i.text for i in soup.select('a.twitter-cashtag.pretty-link.js-nav b')]
""""
print(tweets)
"""
URL_BASE = "https://finviz.com/quote.ashx?t="

with open('_Stocks.csv', 'w', newline='') as file:
    writer = csv.writer(file)

    # note the change
    for tckr in tweets:
        URL = URL_BASE + tckr
        try:
            fpage = urllib.request.urlopen(URL)
            fsoup = BeautifulSoup(fpage, 'html.parser')

            if write_header:
                # note the change
                writer.writerow(['tckr'] + list(map(lambda e: e.text, fsoup.find_all('td', {'class': 'snapshot-td2-cp'}))))
                write_header = False

            # note the change
            writer.writerow([tckr] + list(map(lambda e: e.text, fsoup.find_all('td', {'class': 'snapshot-td2'}))))
        except urllib.request.HTTPError:
            print("{} - not found".format(URL))

with open('_Stocks.csv') as csv_file:
    csv_reader = csv.DictReader(csv_file)

    for line in csv_reader:
        if line['Rel Volume'] > 2.5:
            print(line['tckr'], line['Rel Volume'])

1 个答案:

答案 0 :(得分:0)

看起来你正在使用MySQL数据库,我建议你使用straignt MySQL驱动程序代替Oracle:

Class.forName("com.mysql.jdbc.Driver");
connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/Honeyword","root","qwertyuiop4595");

请发布例外文本。