exceloracle資料庫下載
㈠ java代碼怎樣將oracle資料庫中數據下載本地,為.txt文件或者.excel文件。
第一個類:
package totabel.action;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JOptionPane;
import topdf.TableToPdf;
import totabel.view.TabelData;
import totabel.xls.ExcelDemo;
public class TableAction implements ActionListener {
TabelData data;
public TableAction(TabelData data) {
this.data = data;
}
public void actionPerformed(ActionEvent e) {
String str = e.getActionCommand();
if ("添加".equals(str)) {
data.addData();
} else if ("導出到Excel".equals(str)) {
ExcelDemo demo = new ExcelDemo();
demo.method(data);
} else if ("刪除".equals(str)) {
if (data.getRow() != -1) {
data.delRow();
} else {
JOptionPane.showMessageDialog(null, "請選擇要刪除的行!");
}
}else if("從Excel導入".equals(str)){
data.getXlsInfo();
}else if("從Excel導入到資料庫".equals(str)){
data.toDb();
}else if("從table導出到pdf".equals(str)){
TableToPdf pdf=new TableToPdf();
pdf.newPage(data);
}else if("計算學分".equals(str)){
data.getXlsInfoToCredit();
}
}
}
第二個類:資料庫連接
package totabel.db;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class JdbcConnection {
private static JdbcConnection con;
public static JdbcConnection getCon() {
if (con == null) {
con = new JdbcConnection();
}
return con;
}
public Connection getConnection() {
Connection connection=null;
try {
Class.forName("oracle.jdbc.OracleDriver");
String url = "jdbc:oracle:thin:@127.0.0.1:1521:oracle";
String user = "scott";
String password = "tiger";
connection = DriverManager.getConnection(url, user,
password);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
return connection;
}
// public static void main(String[] args) {
// JdbcConnection connection=new JdbcConnection();
// connection.getConnection("asd", "99");
// }
}
第三個類:主類(入口)
package totabel.db;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class JdbcConnection {
private static JdbcConnection con;
public static JdbcConnection getCon() {
if (con == null) {
con = new JdbcConnection();
}
return con;
}
public Connection getConnection() {
Connection connection=null;
try {
Class.forName("oracle.jdbc.OracleDriver");
String url = "jdbc:oracle:thin:@127.0.0.1:1521:oracle";
String user = "scott";
String password = "tiger";
connection = DriverManager.getConnection(url, user,
password);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
return connection;
}
// public static void main(String[] args) {
// JdbcConnection connection=new JdbcConnection();
// connection.getConnection("asd", "99");
// }
}
第四個類:
package totabel.xls;
import java.io.File;
import java.io.IOException;
import java.util.Vector;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.JOptionPane;
import totabel.view.TabelData;
import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.WriteException;
import jxl.write.biff.RowsExceededException;
public class ExcelDemo {
/**
*
* @param args
*/
private Vector title = new Vector();
private Vector[] array;
// public static void main(String[] args) {
// ExcelDemo demo = new ExcelDemo();
// demo.getXlsInfo();
//
// }
public void method(TabelData table) {
int row = table.getRowSize();
int column = table.getColumnSize();
WritableWorkbook book = null;
Vector title = table.setTitle();
Object[] str = title.toArray();
try {
book = Workbook.createWorkbook(new File("test.xls"));
WritableSheet sheet = book.createSheet("成績表", 0);
for (int i = 0; i < str.length; i++) {
sheet.addCell(new Label(i, 0, (String) str[i]));
}
for (int i = 1; i < row + 1; i++) {
for (int j = 1; j < column + 1; j++) {
sheet.addCell(new Label(j - 1, i, table.getTableInfo(i - 1,
j - 1)));
}
}
book.write();
JOptionPane.showMessageDialog(null, "導出完成!");
} catch (IOException e) {
e.printStackTrace();
} catch (RowsExceededException e) {
e.printStackTrace();
} catch (WriteException e) {
e.printStackTrace();
} finally {
try {
book.close();
} catch (WriteException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
/**
* 輸出Excel的數據到表單
*
* @return
*/
public Vector getXlsInfo() {
Vector v = new Vector();
jxl.Workbook rwb = null;
int index = 0;
try {
rwb = jxl.Workbook.getWorkbook(new File("test.xls"));
Sheet[] sheet = rwb.getSheets();
for (int i = 0; i < sheet.length; i++) {
int rs = sheet[i].getRows();
array = new Vector[rs - 1];
for (int j = 1; j < rs; j++) {
Cell[] cell = sheet[i].getRow(j);
Vector info = new Vector();
for (int k = 0; k < cell.length; k++) {
info.add(cell[k].getContents());
}
array[index] = info;
index++;
v.add(info);
}
Cell[] titleCell = sheet[i].getRow(0);
for (int j = 0; j < titleCell.length; j++) {
title.add(titleCell[j].getContents());
}
}
} catch (BiffException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
rwb.close();
}
return v;
}
public Vector getXlsInfoToCredit() {
Vector v = new Vector();
jxl.Workbook rwb = null;
try {
rwb = jxl.Workbook.getWorkbook(new File("d:/test/信科0821(南遷).xls"));
Sheet[] sheet = rwb.getSheets();
for (int i = 0; i < sheet.length; i++) {
int rs = sheet[i].getRows();
array = new Vector[rs - 1];
for (int j = 1; j < rs; j++) {
Cell[] cell = sheet[i].getRow(j);
Vector info = new Vector();
for (int k = 0; k < cell.length; k++) {
// if(){
Pattern p = Pattern.compile("[0-9]{1,}");
Matcher m = p.matcher(cell[k].getContents());
if (m.matches()) {
int score = Integer.valueOf(cell[k].getContents());
float result = getScore(score);
info.add(result);
} else {
info.add(cell[k].getContents());
}
}
v.add(info);
}
Cell[] titleCell = sheet[i].getRow(0);
for (int j = 0; j < titleCell.length; j++) {
title.add(titleCell[j].getContents());
}
}
} catch (BiffException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
rwb.close();
}
return v;
}
public float getScore(int n) {
float score = n;
if (n < 60) {
score = 0;
return score;
} else {
if (n >= 60 && n <= 63) {
score = (float) 1.0;
} else if (n >= 64 && n <= 67) {
score = (float) 1.3;
} else if (n >= 68 && n <= 71) {
score = (float) 1.7;
} else if (n >= 72 && n <= 75) {
score = (float) 2.0;
} else if (n >= 76 && n <= 79) {
score = (float) 2.3;
} else if (n >= 80 && n <= 83) {
score = (float) 2.7;
} else if (n >= 84 && n <= 87) {
score = (float) 3.0;
} else if (n >= 88 && n <= 91) {
score = (float) 3.3;
} else if (n >= 92 && n <= 95) {
score = (float) 3.7;
} else if (n >= 96 && n <= 100) {
score = (float) 4.0;
}
return score;
}
}
public Vector getTitle() {
// getXlsInfo();
return title;
}
public Vector[] getArray() {
getXlsInfo();
return array;
}
}
因為時間問題就沒有再寫了,上面是我以前做的,不懂就q我
㈡ 怎樣安裝oracle資料庫
1·在oracle官網上下載oracle資料庫,以Oracle Database 11gRelease 2版本的oracle資料庫為例,其他版本的安裝也大同小異。注意,下載前得AcceptLicense Agreement.
㈢ java 怎麼從excel文件導入到oracle資料庫中
java操作excel一般都使用poi來完成:
1、下載poi相關jar,maven的集成如下:(把${poi.version}替換成你要的版本)
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>${poi.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>${poi.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>${poi.version}</version>
<scope>provided</scope>
</dependency>
2、根據poi相關api讀取sheet、row、cell,獲得excel的數據:
封裝row的對象,即每一行數據為一個對象,每個cell為對象里的一個屬性,
整個sheet的數據裝進集合里;
3、處理數據,可以對數據進行驗證或其他操作;
4、寫資料庫操作。
㈣ oracle資料庫下載
在官網下載就可以了,個人是免費下載,幾乎免費使用所有oracle功能,但是現在官網只有oracle 11gR2和oracle 12C兩個版本的下載了。
http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html
㈤ 如何將EXCEL表導入ORACLE資料庫中
操作步驟如下:
准備數據:在excel中構造出需要的數據
OK,至此數據導入成功。
㈥ 如何將Excel導入Oracle資料庫
一、使用工具:Oracle、SQL*Loader、PLSQL Developer、Sql Server 2000。
二、導入方法:有三種導入方法,分別是:
1、方法一:使用SQL*Loader:這個是用的較多的方法,前提必須oracle數據中目的表已經存在。大體步驟如下:
a、將excel文件另存為一個新文件比如文件名為text.txt,文件類型選文本文件(製表符分隔),這里選擇類型為csv(逗號分隔)也行,但是在寫後面的control.ctl時要將欄位終止符改為','(fields
terminated by ','),假設保存到c盤根目錄。
三、注意事項:
1、是注意excel文件的版本和格式要與導入到sql server時的數據源匹配。如果導入到sql
server時的數據源選Microsoft Excel 97-2000的話,而excel文件的版本為Micaosoft Excel 5.0/95
工作簿,則有可能出問題。關於如何看Excle文件格式,你打開excel文件,選擇另存為,即可看到像Micaosoft Excel 5.0/95
工作簿或者是Microsoft Office Excle
工作簿等等其它的保存類型。
2、就是由Sqlserver導入到oracle中時,記得將在oracle中的表名全部用大寫。因為oracle的表名都是大寫的,而sql的表可能是大小混寫的,所以導入後在oracle里查不到該表,比如這個Procts表在oracle里查詢就應該寫成select
* from scott."Procts";
㈦ 如何用Excel直接查詢Oracle中的數據
首先要連接Oracle,方法步驟如下:
1、工具/原料
(1)wps office
2、首先我們控制面板-管理工具-數據源,設置用戶dsn-添加-輸入name一下三項--ok,如圖所示
(1)第一步新建excel表格-數據-其他來源-來自microsoft query
(2)然後選擇剛健的資料庫 oracle --確定,如圖
3、輸入服務名用戶名密碼(前提是你的電腦能連接資料庫,測試方法州答 cmd-tnsping 資料庫名) -ok--excel與資料庫開始建立連接
4、然後我們連接資料庫後所有的表和列都已虧鎮出來,找到自己想要導出的表,註:輸入表名時要一次性輸完,不要停頓哦,要不然查詢不出!如圖
(1)下一步 直到完成 選擇excel哦,點擊excel第一個表格--查看(現有工作表)-確定開始導出資料庫中的表,如圖
以上就是用Excel直接查詢Oracle中的冊空慧數據方法步驟
5、如果上述功能都無法使用,可能是程序出現了問題。建議重新下載安裝試試