oracle 不支持prepareStatement(String sql, String[] columnNames) 了吗

weixin_38429794 2017-05-09 02:28:47

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
public class SaleDao {
private static final String FIND_BY_ID = "select * from sales_tab where id = ?";
private static final String FIND_ALL = "select * from sales_tab";
private static final String SAVEM = "insert into sales_tab (year_id,month_id,day_id,sales_value) values(?,?,?,?)";

public Sale findById(int id){}

public List<Sale> findAll(){}

public boolean save(Sale sale){
try{
Connection conn = DBUtilm.getConnection();
/**
* 为什么当我用DBUtilo连接oracle(v11.2.0)时,下面这行会出错?
* PreparedStatement ps = conn.prepareStatement(SAVEM,new String[]{"id"});
* 然而当我用DBUtilm连接mysql时,程序正常走完?
* 是oracle版本问题吗,我看别人oracle 10g 可以运行的
* 代码应该没有问题
*/
PreparedStatement ps = conn.prepareStatement(SAVEM,new String[]{"id"});
ps.setInt(1,sale.getYear_id());
ps.setInt(2, sale.getMonth_id());
ps.setInt(3, sale.getDay_id());
ps.setInt(4, sale.getSales_value());
if(ps.executeUpdate()>0){
ResultSet rs = ps.getGeneratedKeys();
rs.next();
int id = rs.getInt(1);
sale.setId(id);
ps.close();
return true;
}
ps.close();
}catch(Exception e){
e.getStackTrace();
}finally{
DBUtilo.closeConnection();
}
return false;
}
...全文
277 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
weixin_38429794 2017-05-09
  • 打赏
  • 举报
回复
引用 2 楼 weixin_38429794 的回复:
[quote=引用 1 楼 wmxcn2000 的回复:] 解决了吗,要不要给你移动到 java 区? 建议:把出错的结果也贴出来;
没有出错结果 即使我写了e.getStackTrace(); 但控制台没有任何输出 还未解决 百度后感觉是oracle的问题 行吧 移到Java[/quote] 已解决 ojdbc 版本不对
weixin_38429794 2017-05-09
  • 打赏
  • 举报
回复
引用 1 楼 wmxcn2000 的回复:
解决了吗,要不要给你移动到 java 区? 建议:把出错的结果也贴出来;
没有出错结果 即使我写了e.getStackTrace(); 但控制台没有任何输出 还未解决 百度后感觉是oracle的问题 行吧 移到Java
卖水果的net 2017-05-09
  • 打赏
  • 举报
回复
解决了吗,要不要给你移动到 java 区? 建议:把出错的结果也贴出来;
Delphi 7.1 Update Release Notes=======================================================This file contains important supplemental and late-breakinginformation that may not appear in the main productdocumentation, and supersedes information contained in otherdocuments, including previously installed release notes.Borland recommends that you read this file in its entirety.NOTE: If you are updating a localized version of Delphi 7, visit the Borland Registered User web site to obtain a localized readme file that may contain important late- breaking information not included in this readme file.IMPORTANT: Delphi must be closed before installing this update. =====================================================CONTENTS * INSTALLING THIS UPDATE * UPDATING LOCALIZED VERSIONS OF DELPHI 7 * KNOWN ISSUES * ISSUES ADDRESSED BY THIS UPDATE - IDE - CORE DATABASE - DATASNAP - DBGO (ADO COMPONENTS) - dbExpress - dbExpress COMPONENTS AND DB VCL - dbExpress CORE DRIVER AND METADATA - dbExpress VENDOR ISSUES - dbExpress CERTIFICATION - WEB SNAP - ACTIVEX - COMPILER - RTL - VCL - THIRD PARTY - BOLD FOR DELPHI * VERIFYING THAT THE UPDATE WAS SUCCESSFUL * FILES INSTALLED BY THIS UPDATE =======================================================INSTALLING THIS UPDATE* This update can not be applied to Delphi 7 Architect Trial version. * This update can not be removed after it is installed.* You will need the original Delphi 7 installation CD available to install this update.* To install this update from the CD, insert the CD, and launch the d7_ent_upd1.exe file appropriate for your locale.* To install this update from the Web, double-click the self-executing installation file and follow the prompts. * The Delphi 7 documentation PDF files are available on the update CD.========================================================UPDATING LOCALIZED VERSIONS OF DELPHI 7* This update can be applied only to the English version of Delphi 7. There are separate updates for the German, French and Japanese ver

81,122

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧