我有复杂的查询,创建一个临时表,可能需要5秒钟才能运行或更多.这似乎在同时在类似的表上运行另一个事务时导致死锁.我不能在本地复制,但在生产中我能够每隔几天发生一次.(我记录了mysql错误)
查询非常复杂(显示在页面底部); 但你不需要理解逻辑; 只是它从一堆表和连接中选择,可能需要一段时间才能运行.
我还有一个插入许多相同表的事务.我偶尔会遇到一个mysql错误1213: Deadlock found when trying to get lock; try restarting transaction.
这是交易的伪代码
START TRANSACTION
INSERT INTO phppos_sales
INSERT MANY RECORDS INTO phppos_sales_items
INSERT MANY RECORDS INTO phppos_sales_items_taxes
INSERT MANY RECORDS INTO phppos_sales_payments
END TRANSACTION
Run Code Online (Sandbox Code Playgroud)
How do I go about resolving this deadlock? I tried changing isolation level to READ UNCOMMITTED but mysql settings wouldn't allow for this; and I need to make this work in a variety of environments where I don't have control of …
在ASP中,有request.form和request.queryString属性,但在Java中.好像我们只有一个集合,它可以通过以下方式访问request.getParamaterMap,getParametersNames,getParameterValues等.
有没有办法告诉哪些值已经发布以及哪些值已在URL中指定?
PS:
我想要实现的是创建一个可以处理以下情况的页面
request.getReader()).我正在使用tomcat 6.
根据我到目前为止看到的,如果我发布了一个request.getReader(),发布的值不再出现在getParamater集合中,但仍然存在查询字符串参数.
另一方面,如果我发出任何getParameters方法,则getReader返回空字符串.
好像我不能吃蛋糕也吃.
所以,我想解决方案是:
getReader.request.getParameter有什么好主意吗?
只是为了澄清事情.问题似乎是,getParameter您获得发布的值以及通过URL传递的值,请考虑以下示例:
<%@page import="java.util.*"%>
<%
Integer i;
String name;
String [] values;
for (Enumeration e = request.getParameterNames(); e.hasMoreElements();) {
name = (String) e.nextElement();
values = request.getParameterValues( name …Run Code Online (Sandbox Code Playgroud) 我正在使用Hibernate Tools 3.2.1.GA和Spring 3.0.2版.我想将数据插入到Oracle(10g)数据库字段中clob,如下所示.
Clob c=Hibernate.createClob(request.getParameter("someTextFieldValueOnJSPPage");
pojoObj.setSomeClobProperty(c);
Run Code Online (Sandbox Code Playgroud)
它工作得很好但是当我尝试使用CKEditor插入数据流时, 我的JSP页面上的demo(CKEditor只是呈现HTML <textarea></textarea>元素)可能涉及格式化文本以及图像,flash等,它会抛出以下异常.
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.hibernate.exception.GenericJDBCException: could not update: [model.Cms#1]
Run Code Online (Sandbox Code Playgroud)
org.hibernate.exception.GenericJDBCException: could not update: [model.Cms#1]
Run Code Online (Sandbox Code Playgroud)
java.sql.SQLException: operation not allowed: streams type cannot be used in batching
Run Code Online (Sandbox Code Playgroud)
如何解决该异常?这是Oracle驱动程序问题还是其他什么问题?我正在使用ojdbc14.jar,Oracle JDBC Driver version - 9.0.2.0.0.
更新:
使用该Clob类型的实体之一是
public class Cms implements java.io.Serializable
{
private BigDecimal cmsId;
private Clob aboutUs; //I'm currently dealing with this …Run Code Online (Sandbox Code Playgroud) 我想用只有一个每个操作的通用方法,包装类型等而进行像加,减,乘,除基本的算术运算Integer,Float,Double...(不BigDecimal和BigInteger).
我尝试使用泛型类做类似以下的事情(用于添加).
public final class GenericClass<E extends Number> {
public E add(E x, E y) {
return x + y; // Compile-time error
}
}
Run Code Online (Sandbox Code Playgroud)
它发出编译时错误,
operator +不能应用于E,E
有没有办法使用这样的通用版本来实现这样的操作?
我有一个问题,因为Hibernate 4.1.8导致以下异常:
org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [test.hibernate.TestPrepravkaOsobaSAdresou$Uvazek#2]
Run Code Online (Sandbox Code Playgroud)
我在两个实体之间有一个简单的OneToMany关联:
@Entity(name = "Ppv")
@Table(name = "PPV")
public static class Ppv {
@Id
Long ppvId;
@OneToMany(fetch = FetchType.EAGER, mappedBy = "ppv")
Set<Uvazek> uvazeks = new HashSet<Uvazek>(0);
}
@Entity(name = "Uvazek")
@Table(name = "UVAZEK")
public static class Uvazek {
@Id
Long uvazekId;
@ManyToOne
@JoinColumn(name = "PPV_FXID")
Ppv ppv;
}
Run Code Online (Sandbox Code Playgroud)
和一个测试案例,我有一个Ppv和两个Uvazek.当我加载和分离Ppv时,删除一个与加载的Ppv相关联的Uvazek并合并Ppv我得到一个异常.
jdbcTemplate.execute("insert into PPV values(1)");
jdbcTemplate.execute("insert into UVAZEK values(2, 1)");
jdbcTemplate.execute("insert into UVAZEK values(3, 1)");
Ppv ppv = (Ppv) getSession().get(Ppv.class, 1l); …Run Code Online (Sandbox Code Playgroud) 我收到一个java.util.List<Object[]>via JSON-rpc作为JavaScript数组,如下所示.
[
[1, 0.10, 1.00],
[2, 0.20, 2.00],
[3, 0.30, 3.00],
[4, 0.40, 4.00],
[5, 0.50, 5.00],
[6, 0.60, 6.00],
[7, 0.70, 7.00],
[8, 0.80, 8.00],
[9, 0.90, 9.00],
[10, 1.00, 10.00],
[11, 1.10, 11.00],
[12, 1.20, 12.00],
[13, 1.30, 13.00],
[14, 1.40, 14.00],
[15, 1.50, 15.00],
[16, 1.60, 16.00],
[17, 1.70, 17.00],
[18, 1.80, 18.00]
]
Run Code Online (Sandbox Code Playgroud)
我需要将同一个数组传递回服务器(在最后一个维度稍作修改).
我使用以下函数发回这个数组.
var request;
var timeout;
var itemsArray=[];
function insert()
{
if(!request)
{
var i=0;
$('input[name="txtCharge[]"]').each(function()
{
isNaN($(this).val())||$(this).val()===''?itemsArray[i][2]='':itemsArray[i][2]=eval(eval($(this).val()).toFixed(2));
i++;
}); …Run Code Online (Sandbox Code Playgroud) 我知道我们需要显式添加process="@this"以获取p:commandbutton调用的操作,并且我也知道process属性默认为@formprimefaces.
由于进程是默认的,@form因此按钮也不会与表单中的其他元素一起处理,并且应该调用其操作.
任何人都可以解释这背后的确切原因吗?
例如,
XSSFCellStyle style=(XSSFCellStyle) workbook.createCellStyle();
style.setDataFormat(workbook.createDataFormat().getFormat("#.##"));
productCell.setCellValue(12.4);
productCell.setCellType(Cell.CELL_TYPE_NUMERIC);
productCell.setCellStyle(style);
Run Code Online (Sandbox Code Playgroud)
这将显示12.4在指定的单元格中.它应该是12.40.12显示的值12.非常不必要.
如果该值是0,则显示一个点..它应始终显示两位小数 - 0.00在这种情况下,无论存储在单元格中的值如何.
如何强制excel始终在数字单元格中显示两位小数?
我使用以下样式之一来显示数字单元格.
XSSFColor commonColor = new XSSFColor(new java.awt.Color(240, 240, 240));
XSSFColor cellBorderColour = new XSSFColor(new java.awt.Color(0, 76, 153));
Font font = workbook.createFont();
font.setBoldweight(Font.BOLDWEIGHT_BOLD);
font.setColor(IndexedColors.DARK_BLUE.index);
XSSFCellStyle style = (XSSFCellStyle) workbook.createCellStyle();
style.setFillForegroundColor(commonColor);
style.setFillPattern(CellStyle.SOLID_FOREGROUND);
style.setAlignment(CellStyle.ALIGN_RIGHT);
style.setFont(font);
style.setBorderLeft(BorderStyle.HAIR);
style.setBorderColor(XSSFCellBorder.BorderSide.LEFT, cellBorderColour);
style.setBorderTop(BorderStyle.HAIR);
style.setBorderColor(XSSFCellBorder.BorderSide.TOP, cellBorderColour);
style.setBorderRight(BorderStyle.HAIR);
style.setBorderColor(XSSFCellBorder.BorderSide.RIGHT, cellBorderColour);
style.setBorderBottom(BorderStyle.DOUBLE);
style.setBottomBorderColor(cellBorderColour);
Run Code Online (Sandbox Code Playgroud)
我应用了一些excel公式来对数字单元格执行一些计算,这些数字单元格应该在数字单元格上应用数字格式(向上舍入一半)之后执行.
我跟随php mysql新手到忍者:
下面的表单模板
<form action="?" method="post">
<div>
<label for="joketext">Type your joke here:</label>
<textarea id="joketext" name="joketext" rows="3" cols="40"></textarea>
</div>
<div><input type="submit" value="Add"></div>
</form>
Run Code Online (Sandbox Code Playgroud)
PHP控制器的一部分:
if(isset($_POST['joketext'])) //insert block
{
try
{ //prepared starement
$sql = 'INSERT INTO joke SET
joketext = :joketext,
jokedate = CURDATE()';
Run Code Online (Sandbox Code Playgroud)
什么是'?' 做形式动作
在我的项目中,我在持久层中使用JSF + JPA + CDI + WildFly 8.2.我有一个BasicDao,像这样:
public class BasicDao<M, K> {
private org.jboss.logging.Logger logger = org.jboss.logging.Logger
.getLogger("BasicDao");
@Inject
@Primary
protected EntityManager em;
Class<M> mclass;
public EntityManager getEm() {
return em;
}
public void setEm(EntityManager em) {
this.em = em;
}
@Transactional(value=TxType.NOT_SUPPORTED)
public M find(K id){
return em.find(mclass, id);
}
@Transactional(value=TxType.REQUIRED)
public void insert(M inst){
this.em.persist(inst);
}
@SuppressWarnings("unchecked")
@Transactional(value=TxType.REQUIRED)
public K insertWithAutoId(M inst){
this.em.persist(inst);
return (K) this.em.getEntityManagerFactory().getPersistenceUnitUtil().getIdentifier(inst);
}
@Transactional(value=TxType.REQUIRED)
public M update(M updated){
return this.em.merge(updated);
}
@Transactional(value=TxType.REQUIRED)
public void …Run Code Online (Sandbox Code Playgroud)