很抱歉,我第一次发布任何内容。...我正在尝试将旧的Java / JSF应用程序升级到tomcat 8,JSF 1.2和JDK 1.6。我在数据转换器上遇到交互式错误。
尝试保存时出现以下错误:Screenshot
#{currentRow.value['horseledger.DATE']}' Cannot convert [3/31/19 12:00 AM] of type [class java.util.Date] to [class java.sql.Date]
这是JSF代码:
<?xml version="1.0" encoding="UTF-8"?>
<jsp:root version="2.1" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:webuijsf="http://www.sun.com/webui/webuijsf">
<jsp:directive.page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"/>
<f:view>
<webuijsf:page id="page1">
<webuijsf:html id="html1">
<webuijsf:head id="head1">
<webuijsf:link id="link1" url="/resources/stylesheet.css"/>
</webuijsf:head>
<webuijsf:body id="body1" style="-rave-layout: grid">
<webuijsf:form binding="#{PartnerTrans.form1}" id="form1" virtualFormsConfig="partner | partnerDD | partnerDD , statement | statementDD | statementDD , save | table1:tableRowGroup1:tableColumn2:dropDown1 table1:tableRowGroup1:tableColumn5:textField3 table1:tableRowGroup1:tableColumn6:textField4 table1:tableRowGroup1:tableColumn3:textField1 table1:tableRowGroup1:tableColumn4:textField2 | savebtn , add/delete | | table1:tableRowGroup1:tableColumn7:button1 addbtn">
<div style="position: absolute; left: 48px; top: 0px">
<jsp:directive.include file="header.jspf"/>
</div>
<webuijsf:label id="label1" labelLevel="1" style="position: absolute; left: 48px; top: 120px" text="Partner:"/>
<webuijsf:label id="label2" labelLevel="1" style="position: absolute; left: 48px; top: 144px" text="Statement:"/>
<webuijsf:table augmentTitle="false" id="table1" style="position: absolute; left: 48px; top: 216px" title="Transactions" width="560">
<webuijsf:tableRowGroup binding="#{PartnerTrans.tableRowGroup1}" id="tableRowGroup1" rows="10"
sourceData="#{PartnerTrans.partnerledgerDataProvider}" sourceVar="currentRow">
<webuijsf:tableColumn headerText="Transaction" id="tableColumn2">
<webuijsf:dropDown converter="#{PartnerTrans.dropDown1Converter}" id="dropDown1"
items="#{PartnerTrans.partnertranstypeDataProvider.options['transtype.TRANSTYPE,transtype.TRANSDESC']}" selected="#{currentRow.value['partnerledger.TRANSTYPE']}"/>
<webuijsf:message for="dropDown1" id="message1" showDetail="false" showSummary="true"/>
</webuijsf:tableColumn>
<webuijsf:tableColumn headerText="Units" id="tableColumn3" sort="partnerledger.UNITS">
<webuijsf:textField id="textField1" text="#{currentRow.value['partnerledger.UNITS']}"/>
<webuijsf:message for="textField1" id="message2" showDetail="false" showSummary="true"/>
</webuijsf:tableColumn>
<webuijsf:tableColumn headerText="Unit Price" id="tableColumn4" sort="partnerledger.UNITPRICE">
<webuijsf:textField id="textField2" text="#{currentRow.value['partnerledger.UNITPRICE']}"/>
<webuijsf:message for="textField2" id="message3" showDetail="false" showSummary="true"/>
</webuijsf:tableColumn>
<webuijsf:tableColumn headerText="Total" id="tableColumn1" width="20">
<webuijsf:staticText converter="#{PartnerTrans.numberConverter1}" id="staticText1" text="#{currentRow.value['partnerledger.UNITS'] * currentRow.value['partnerledger.UNITPRICE']}"/>
</webuijsf:tableColumn>
<webuijsf:tableColumn headerText="Date" id="tableColumn5" sort="partnerledger.DATE">
<webuijsf:textField converter="#{PartnerTrans.dateTimeConverter1}" id="textField3" text="#{currentRow.value['partnerledger.DATE']}"/>
<webuijsf:message for="textField3" id="message4" showDetail="false" showSummary="true"/>
</webuijsf:tableColumn>
<webuijsf:tableColumn headerText="Notes" id="tableColumn6" sort="partnerledger.NOTES">
<webuijsf:textField id="textField4" text="#{currentRow.value['partnerledger.NOTES']}"/>
<webuijsf:message for="textField4" id="message5" showDetail="false" showSummary="true"/>
</webuijsf:tableColumn>
<webuijsf:tableColumn headerText="Delete" id="tableColumn7">
<webuijsf:button actionExpression="#{PartnerTrans.button1_action}" id="button1" text="Delete"/>
</webuijsf:tableColumn>
</webuijsf:tableRowGroup>
</webuijsf:table>
<webuijsf:button actionExpression="#{PartnerTrans.addbtn_action}" id="addbtn"
style="left: 72px; top: 192px; position: absolute; width: 150px" text="Add Transaction"/>
<webuijsf:button actionExpression="#{PartnerTrans.savebtn_action}" id="savebtn"
style="left: 240px; top: 192px; position: absolute; width: 150px" text="Save Changes"/>
<webuijsf:button actionExpression="#{PartnerTrans.returnbtn_action}" id="returnbtn"
style="left: 408px; top: 192px; position: absolute; width: 150px" text="Return to Menu"/>
<webuijsf:staticText id="staticText2" style="position: absolute; left: 432px; top: 144px" text="Statement Total:"/>
<webuijsf:staticText binding="#{PartnerTrans.totalstxt}" converter="#{PartnerTrans.numberConverter1}" id="totalstxt" style="position: absolute; left: 528px; top: 144px"/>
<webuijsf:messageGroup id="messageGroup1" style="left: 624px; top: 144px; position: absolute"/>
<webuijsf:dropDown binding="#{PartnerTrans.statementDD}" converter="#{PartnerTrans.bigDecimalConverter1}" id="statementDD"
items="#{PartnerTrans.statementdatesDataProvider.options['statementdates.STATEMENTID,statementdates.STATEDESC']}"
onChange="webui.suntheme.common.timeoutSubmitForm(this.form, 'statementDD');" style="position: absolute; left: 144px; top: 144px" valueChangeListenerExpression="#{PartnerTrans.statementDD_processValueChange}"/>
<webuijsf:dropDown binding="#{PartnerTrans.partnerDD}" converter="#{PartnerTrans.bigDecimalConverter2}" id="partnerDD"
items="#{PartnerTrans.partnersDataProvider.options['partners.PARTNERID,partners.PARTNERNAME']}"
onChange="webui.suntheme.common.timeoutSubmitForm(this.form, 'partnerDD');" style="position: absolute; left: 144px; top: 120px" valueChangeListenerExpression="#{PartnerTrans.partnerDD_processValueChange}"/>
</webuijsf:form>
</webuijsf:body>
</webuijsf:html>
</webuijsf:page>
</f:view>
</jsp:root>
这是Java代码:
/*
* PartnerTrans.java
*
* Created on July 10, 2007, 12:12 AM
* Copyright ketnera
*/
package renpheracctv5;
import com.sun.data.provider.RowKey;
import com.sun.data.provider.impl.CachedRowSetDataProvider;
import com.sun.rave.web.ui.appbase.AbstractPageBean;
import com.sun.webui.jsf.component.Body;
import com.sun.webui.jsf.component.Button;
import com.sun.webui.jsf.component.DropDown;
import com.sun.webui.jsf.component.Form;
import com.sun.webui.jsf.component.Head;
import com.sun.webui.jsf.component.Html;
import com.sun.webui.jsf.component.Label;
import com.sun.webui.jsf.component.Link;
import com.sun.webui.jsf.component.Message;
import com.sun.webui.jsf.component.MessageGroup;
import com.sun.webui.jsf.component.Page;
import com.sun.webui.jsf.component.StaticText;
import com.sun.webui.jsf.component.Table;
import com.sun.webui.jsf.component.TableColumn;
import com.sun.webui.jsf.component.TableRowGroup;
import com.sun.webui.jsf.component.TextField;
import com.sun.webui.jsf.model.SingleSelectOptionsList;
import java.math.BigDecimal;
import javax.faces.FacesException;
import javax.faces.convert.BigDecimalConverter;
import javax.faces.convert.DateTimeConverter;
import javax.faces.convert.NumberConverter;
import javax.faces.event.ValueChangeEvent;
/**
* <p>Page bean that corresponds to a similarly named JSP page. This
* class contains component definitions (and initialization code) for
* all components that you have defined on this page, as well as
* lifecycle methods and event handlers where you may add behavior
* to respond to incoming events.</p>
*/
public class PartnerTrans extends AbstractPageBean {
// <editor-fold defaultstate="collapsed" desc="Managed Component Definition">
private int __placeholder;
/**
* <p>Automatically managed component initialization. <strong>WARNING:</strong>
* This method is automatically generated, so any user-specified code inserted
* here is subject to being replaced.</p>
*/
private void _init() throws Exception {
statementdatesDataProvider.setCachedRowSet((javax.sql.rowset.CachedRowSet)getValue("#{SessionBean1.statementdatesRowSet}"));
partnersDataProvider.setCachedRowSet((javax.sql.rowset.CachedRowSet)getValue("#{SessionBean1.partnersRowSet}"));
partnerledgerDataProvider.setCachedRowSet((javax.sql.rowset.CachedRowSet)getValue("#{SessionBean1.partnerledgerRowSet}"));
partnertranstypeDataProvider.setCachedRowSet((javax.sql.rowset.CachedRowSet)getValue("#{SessionBean1.partnertranstypeRowSet}"));
dateTimeConverter1.setTimeZone(null);
dateTimeConverter1.setPattern("MM/dd/yyyy");
numberConverter1.setMinIntegerDigits(1);
numberConverter1.setMaxIntegerDigits(40);
numberConverter1.setMaxFractionDigits(3);
numberConverter1.setType("currency");
numberConverter1.setCurrencySymbol("$");
}
private Form form1 = new Form();
public Form getForm1() {
return form1;
}
public void setForm1(Form f) {
this.form1 = f;
}
private CachedRowSetDataProvider statementdatesDataProvider = new CachedRowSetDataProvider();
public CachedRowSetDataProvider getStatementdatesDataProvider() {
return statementdatesDataProvider;
}
public void setStatementdatesDataProvider(CachedRowSetDataProvider crsdp) {
this.statementdatesDataProvider = crsdp;
}
private BigDecimalConverter statementDDConverter = new BigDecimalConverter();
public BigDecimalConverter getStatementDDConverter() {
return statementDDConverter;
}
public void setStatementDDConverter(BigDecimalConverter bdc) {
this.statementDDConverter = bdc;
}
private CachedRowSetDataProvider partnersDataProvider = new CachedRowSetDataProvider();
public CachedRowSetDataProvider getPartnersDataProvider() {
return partnersDataProvider;
}
public void setPartnersDataProvider(CachedRowSetDataProvider crsdp) {
this.partnersDataProvider = crsdp;
}
private BigDecimalConverter partnerDDConverter = new BigDecimalConverter();
public BigDecimalConverter getPartnerDDConverter() {
return partnerDDConverter;
}
public void setPartnerDDConverter(BigDecimalConverter bdc) {
this.partnerDDConverter = bdc;
}
private TableRowGroup tableRowGroup1 = new TableRowGroup();
public TableRowGroup getTableRowGroup1() {
return tableRowGroup1;
}
public void setTableRowGroup1(TableRowGroup trg) {
this.tableRowGroup1 = trg;
}
private CachedRowSetDataProvider partnerledgerDataProvider = new CachedRowSetDataProvider();
public CachedRowSetDataProvider getPartnerledgerDataProvider() {
return partnerledgerDataProvider;
}
public void setPartnerledgerDataProvider(CachedRowSetDataProvider crsdp) {
this.partnerledgerDataProvider = crsdp;
}
private CachedRowSetDataProvider partnertranstypeDataProvider = new CachedRowSetDataProvider();
public CachedRowSetDataProvider getPartnertranstypeDataProvider() {
return partnertranstypeDataProvider;
}
public void setPartnertranstypeDataProvider(CachedRowSetDataProvider crsdp) {
this.partnertranstypeDataProvider = crsdp;
}
private BigDecimalConverter dropDown1Converter = new BigDecimalConverter();
public BigDecimalConverter getDropDown1Converter() {
return dropDown1Converter;
}
public void setDropDown1Converter(BigDecimalConverter bdc) {
this.dropDown1Converter = bdc;
}
private DateTimeConverter dateTimeConverter1 = new DateTimeConverter();
public DateTimeConverter getDateTimeConverter1() {
return dateTimeConverter1;
}
public void setDateTimeConverter1(DateTimeConverter dtc) {
this.dateTimeConverter1 = dtc;
}
private StaticText totalstxt = new StaticText();
public StaticText getTotalstxt() {
return totalstxt;
}
public void setTotalstxt(StaticText st) {
this.totalstxt = st;
}
private NumberConverter numberConverter1 = new NumberConverter();
public NumberConverter getNumberConverter1() {
return numberConverter1;
}
public void setNumberConverter1(NumberConverter nc) {
this.numberConverter1 = nc;
}
private DropDown statementDD = new DropDown();
public DropDown getStatementDD() {
return statementDD;
}
public void setStatementDD(DropDown dd) {
this.statementDD = dd;
}
private BigDecimalConverter bigDecimalConverter1 = new BigDecimalConverter();
public BigDecimalConverter getBigDecimalConverter1() {
return bigDecimalConverter1;
}
public void setBigDecimalConverter1(BigDecimalConverter bdc) {
this.bigDecimalConverter1 = bdc;
}
private DropDown partnerDD = new DropDown();
public DropDown getPartnerDD() {
return partnerDD;
}
public void setPartnerDD(DropDown dd) {
this.partnerDD = dd;
}
private BigDecimalConverter bigDecimalConverter2 = new BigDecimalConverter();
public BigDecimalConverter getBigDecimalConverter2() {
return bigDecimalConverter2;
}
public void setBigDecimalConverter2(BigDecimalConverter bdc) {
this.bigDecimalConverter2 = bdc;
}
// </editor-fold>
/**
* <p>Construct a new Page bean instance.</p>
*/
public PartnerTrans() {
}
/**
* <p>Callback method that is called whenever a page is navigated to,
* either directly via a URL, or indirectly via page navigation.
* Customize this method to acquire resources that will be needed
* for event handlers and lifecycle methods, whether or not this
* page is performing post back processing.</p>
*
* <p>Note that, if the current request is a postback, the property
* values of the components do <strong>not</strong> represent any
* values submitted with this request. Instead, they represent the
* property values that were saved for this view when it was rendered.</p>
*/
public boolean add;
public void init() {
// Perform initializations inherited from our superclass
super.init();
// Perform application initialization that must complete
// *before* managed components are initialized
// TODO - add your own initialiation code here
// <editor-fold defaultstate="collapsed" desc="Managed Component Initialization">
// Initialize automatically managed components
// *Note* - this logic should NOT be modified
try {
_init();
} catch (Exception e) {
log("PartnerTrans Initialization Failure", e);
throw e instanceof FacesException ? (FacesException) e: new FacesException(e);
}
// </editor-fold>
// Perform application initialization that must complete
// *after* managed components are initialized
// TODO - add your own initialization code here
}
/**
* <p>Callback method that is called after the component tree has been
* restored, but before any event processing takes place. This method
* will <strong>only</strong> be called on a postback request that
* is processing a form submit. Customize this method to allocate
* resources that will be required in your event handlers.</p>
*/
public void preprocess() {
}
/**
* <p>Callback method that is called just before rendering takes place.
* This method will <strong>only</strong> be called for the page that
* will actually be rendered (and not, for example, on a page that
* handled a postback and then navigated to a different page). Customize
* this method to allocate resources that will be required for rendering
* this page.</p>
*/
public void prerender() {
if (partnerDD.getSelected() == null) {
Object firstPartnerId = null;
Object firstStatementId = null;
try {
partnersDataProvider.cursorFirst();
firstPartnerId = partnersDataProvider.getValue("partners.PARTNERID");
partnerDD.setSelected(firstPartnerId);
statementdatesDataProvider.cursorFirst();
firstStatementId = statementdatesDataProvider.getValue("statementdates.STATEMENTID");
statementDD.setSelected(firstStatementId);
getSessionBean1().getPartnerledgerRowSet().setObject(1, firstPartnerId);
getSessionBean1().getPartnerledgerRowSet().setObject(2, firstStatementId);
partnerledgerDataProvider.refresh();
} catch (Exception e) {
log("Error Description", e);
error(e.getMessage());
}
}
try {
if (add == false){
BigDecimal totalValue = new BigDecimal("0.0");
partnerledgerDataProvider.cursorFirst();
int rows = partnerledgerDataProvider.getRowCount();
for (int i=0; i < rows; i++){
BigDecimal value = (BigDecimal) partnerledgerDataProvider.getValue("partnerledger.UNITS");
BigDecimal price = (BigDecimal) partnerledgerDataProvider.getValue("partnerledger.UNITPRICE");
value = value.multiply(price);
if (value != null){
totalValue = totalValue.add(value);
}
partnerledgerDataProvider.cursorNext();
}
totalstxt.setValue(totalValue);
} else {
add = false;
}
} catch (Exception e) {
log("Error Description", e);
error(e.getMessage());
}
}
/**
* <p>Callback method that is called after rendering is completed for
* this request, if <code>init()</code> was called (regardless of whether
* or not this was the page that was actually rendered). Customize this
* method to release resources acquired in the <code>init()</code>,
* <code>preprocess()</code>, or <code>prerender()</code> methods (or
* acquired during execution of an event handler).</p>
*/
public void destroy() {
statementdatesDataProvider.close();
partnersDataProvider.close();
partnerledgerDataProvider.close();
partnertranstypeDataProvider.close();
}
/**
* <p>Return a reference to the scoped data bean.</p>
*/
protected ApplicationBean1 getApplicationBean1() {
return (ApplicationBean1)getBean("ApplicationBean1");
}
/**
* <p>Return a reference to the scoped data bean.</p>
*/
protected RequestBean1 getRequestBean1() {
return (RequestBean1)getBean("RequestBean1");
}
/**
* <p>Return a reference to the scoped data bean.</p>
*/
protected SessionBean1 getSessionBean1() {
return (SessionBean1)getBean("SessionBean1");
}
public void partnerDD_processValueChange(ValueChangeEvent event) {
Object selectedpartner = partnerDD.getSelected();
Object selectedStatement = statementDD.getSelected();
try {
partnersDataProvider.setCursorRow(partnersDataProvider.findFirst("partners.PARTNERID", selectedpartner));
statementdatesDataProvider.setCursorRow(statementdatesDataProvider.findFirst("statementdates.STATEMENTID", selectedStatement));
getSessionBean1().getPartnerledgerRowSet().setObject(1, selectedpartner);
getSessionBean1().getPartnerledgerRowSet().setObject(2, selectedStatement);
partnerledgerDataProvider.refresh();
form1.discardSubmittedValues("save");
} catch (Exception e) {
log("Error Description", e);
error(e.getMessage());
}
}
public void statementDD_processValueChange(ValueChangeEvent event) {
// ledgerTbl.setVisible(true);
Object selectedStatement = statementDD.getSelected();
Object selectedPartner = partnerDD.getSelected();
try {
statementdatesDataProvider.setCursorRow(statementdatesDataProvider.findFirst("statementdates.STATEMENTID", selectedStatement));
getSessionBean1().getPartnerledgerRowSet().setObject(1, selectedPartner);
getSessionBean1().getPartnerledgerRowSet().setObject(2, selectedStatement);
partnerledgerDataProvider.refresh();
form1.discardSubmittedValues("save");
} catch (Exception e) {
log("Error Description", e);
error(e.getMessage());
}
}
public String addbtn_action() {
try {
RowKey rk = partnerledgerDataProvider.appendRow();
partnerledgerDataProvider.setCursorRow(rk);
partnerledgerDataProvider.setValue("partnerledger.PARTNERID", partnerDD.getSelected());
partnerledgerDataProvider.setValue("partnerledger.TRANSTYPE", new BigDecimal(1));
partnerledgerDataProvider.setValue("partnerledger.STATEMENTID", statementDD.getSelected());
partnerledgerDataProvider.setValue("partnerledger.UNITS", new BigDecimal(0.0));
partnerledgerDataProvider.setValue("partnerledger.UNITPRICE", new BigDecimal(0.0));
add = true;
} catch (Exception e) {
log("Error Description", e);
error(e.getMessage());
}
return null;
}
public String savebtn_action() {
try {
partnerledgerDataProvider.commitChanges();
partnerledgerDataProvider.refresh();
} catch (Exception e){
log("Error Description", e);
error(e.getMessage());
}
return null;
}
public String button1_action() {
form1.discardSubmittedValues("save");
try {
RowKey rk = tableRowGroup1.getRowKey();
if (rk != null) {
partnerledgerDataProvider.removeRow(rk);
partnerledgerDataProvider.commitChanges();
partnerledgerDataProvider.refresh();}
} catch (Exception ex) {
log("Error Description", ex);
error(ex.getMessage());
}
return null;
}
public String returnbtn_action() {
// TODO: Process the action. Return value is a navigation
// case name where null will return to the same page.
return "case1";
}
}
会话bean的行
partnersRowSet.setDataSourceName("java:comp/env/jdbc/renpherdbv2_MYSQL");
partnersRowSet.setCommand("SELECT ALL partners.`PARTNERID`, partners.`PARTNERNAME`, partners.`ADDRESS1`, partners.`ADDRESS2`, partners.`CITY`, partners.`STATE`, partners.`ZIP`, partners.`EMAIL`, partners.`TAXID`, partners.`CELLPHONE`, partners.`ALTPHONE` FROM partners ORDER BY partners.`PARTNERNAME` ASC");
partnersRowSet.setTableName("partners");
statementdatesRowSet.setDataSourceName("java:comp/env/jdbc/renpherdbv2_MYSQL");
statementdatesRowSet.setCommand("SELECT * FROM statementdates");
statementdatesRowSet.setTableName("statementdates");
partnerledgerRowSet.setDataSourceName("java:comp/env/jdbc/renpherdbv2_MYSQL");
partnerledgerRowSet.setCommand("SELECT ALL partnerledger.PARTNERID, \n partnerledger.TRANSTYPE, \n partnerledger.UNITS, \n partnerledger.UNITPRICE, \n partnerledger.DATE, \n partnerledger.NOTES, \n partnerledger.STATEMENTID, \n partnerledger.TRANSID \nFROM partnerledger\nWHERE partnerledger.PARTNERID = ?\n AND partnerledger.STATEMENTID = ? ");
partnerledgerRowSet.setTableName("partnerledger");
partnertranstypeRowSet.setDataSourceName("java:comp/env/jdbc/renpherdbv2_MYSQL");
partnertranstypeRowSet.setCommand("SELECT ALL transtype.TRANSTYPE, \n transtype.TRANSDESC, \n transtype.HORSEPARTNER \nFROM transtype\nWHERE transtype.HORSEPARTNER = 'P' ");
partnertranstypeRowSet.setTableName("transtype");
数据库是MySql,其字段类型为DATE。这是表DDL:
CREATE TABLE `partnerledger` (
`PARTNERID` decimal(7,0) DEFAULT NULL,
`TRANSTYPE` decimal(7,0) DEFAULT NULL,
`UNITS` decimal(8,2) DEFAULT NULL,
`UNITPRICE` decimal(10,2) DEFAULT NULL,
`DATE` date DEFAULT NULL,
`NOTES` varchar(50) DEFAULT NULL,
`STATEMENTID` decimal(7,0) DEFAULT NULL,
`TRANSID` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`TRANSID`),
KEY `PARTNERID` (`PARTNERID`),
KEY `STATEMENTID` (`STATEMENTID`)
) ENGINE=InnoDB AUTO_INCREMENT=11569 DEFAULT CHARSET=latin1
CREATE TABLE `statementdates` (
`STATEMENTID` decimal(7,0) NOT NULL,
`STATEDESC` varchar(20) DEFAULT NULL,
`STARTDATE` date DEFAULT NULL,
`ENDDATE` date DEFAULT NULL,
PRIMARY KEY (`STATEMENTID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
CREATE TABLE `transtype` (
`TRANSTYPE` decimal(7,0) NOT NULL,
`TRANSDESC` varchar(30) DEFAULT NULL,
`HORSEPARTNER` char(1) NOT NULL,
PRIMARY KEY (`TRANSTYPE`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
CREATE TABLE `partners` (
`PARTNERID` decimal(7,0) NOT NULL,
`PARTNERNAME` varchar(35) DEFAULT NULL,
`ADDRESS1` varchar(30) DEFAULT NULL,
`ADDRESS2` varchar(30) DEFAULT NULL,
`CITY` varchar(30) DEFAULT NULL,
`STATE` varchar(2) DEFAULT NULL,
`ZIP` decimal(9,0) DEFAULT NULL,
`EMAIL` varchar(50) DEFAULT NULL,
`TAXID` varchar(20) DEFAULT NULL,
`CELLPHONE` varchar(15) DEFAULT NULL,
`ALTPHONE` varchar(15) DEFAULT NULL,
`USERNAME` varchar(15) DEFAULT NULL,
`PASSWORD` varchar(15) DEFAULT NULL,
`ACTIVE` tinyint(1) NOT NULL DEFAULT '1',
PRIMARY KEY (`PARTNERID`),
KEY `PARTNERNAME` (`PARTNERNAME`),
KEY `ACTIVE` (`ACTIVE`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
tomcat日志中没有错误。
我感觉这可能是一个类问题,因为在整个项目中没有java.util.date或java.sql.date的导入。也许是一个mysql连接器。使用mysql-connector-java-5.1.47.jar
作为更新也正在应用程序中的所有日期进行,因此我猜测它是jdbc或mysql连接器问题,但不确定如何解决。
答案 0 :(得分:0)
创建了一个自定义转换器,将java.util.date转换为java.sql.date。我将在短期内增加处理不同格式的功能,但是这样做是为了使应用程序正常工作!代码如下:
public class CustSQLDateConverter implements Converter
{
private String dateFormat = new String();
public void SetDateFormat (String df)
{
dateFormat = df;
}
@Override
public Object getAsObject(FacesContext context, UIComponent component,
String value)
{
SimpleDateFormat format = new SimpleDateFormat(dateFormat);
Date parsed = null;
try {
parsed = format.parse(value);
} catch(ParseException pe)
{
pe.printStackTrace();
}
java.sql.Date sql = new java.sql.Date(parsed.getTime());
return (sql);
}
public String getAsString(FacesContext context, UIComponent component,
Object value)
{
String dtstring = value.toString();
String[] dt = dtstring.split("-");
String fmtDate = dt[1] + "/" + dt[2] + "/" + dt[0];
return fmtDate;
}
}