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、如果上述功能都无法使用,可能是程序出现了问题。建议重新下载安装试试