我试图将照片插入MySQL表的BLOB列,我得到一个例外:
Data too long for column 'logo' at row 1.
Run Code Online (Sandbox Code Playgroud)
这是JDBC:
int idRestaurant = 42;
String restoname= "test";
String restostatus= "test";
InputStream fileContent = getUploadedFile();
int fileSize = getUploadedFileSize();
Class.forName("com.mysql.jdbc.Driver");
try (Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/resto" , "root" , "" )) {
PreparedStatement ps = conn.prepareStatement("insert into restaurants (idRestaurant, restaurantName, status, logo) values(?,?,?,?)");
ps.setInt(1, idRestaurant);
ps.setString(2, restoname);
ps.setString(3, restostatus);
ps.setBinaryStream(4, fileContent, fileSize);
ps.executeUpdate();
conn.commit();
}
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?
我有这个代码可以检查/取消选中所有复选框,然后选中/取消选中一个复选框.
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Persist checkboxes</title>
</head>
<body>
<div>
<label for="checkAll">Check all</label>
<input type="checkbox" id="checkAll">
</div>
<div>
<label for="option1">Option 1</label>
<input type="checkbox" id="option1">
</div>
<div>
<label for="option2">Option 2</label>
<input type="checkbox" id="option2">
</div>
<div>
<label for="option3">Option 3</label>
<input type="checkbox" id="option3">
</div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="http://cdn.jsdelivr.net/jquery.cookie/1.4.0/jquery.cookie.min.js"></script>
<script>
$("#checkAll").on("change", function() {
$(':checkbox').not(this).prop('checked', this.checked);
});
$(":checkbox").on("change", function(){
var checkboxValues = {};
$(":checkbox").each(function(){
checkboxValues[this.id] = this.checked;
});
$.cookie('checkboxValues', checkboxValues, { expires: 7, path: '/' })
});
function repopulateCheckboxes(){
var checkboxValues = $.cookie('checkboxValues'); …Run Code Online (Sandbox Code Playgroud) 我是jquery和localstorage的新手。我想对所有使用jquery的文本框使用localstorage。
<input id="in-1" type="text" />
<br />
<input id="in-2" type="text" />
<br />
<input id="in-3" type="text" />
<br />
<input id="in-4" type="text" />
<br />
Run Code Online (Sandbox Code Playgroud)
我正在尝试遵循以下脚本:
(function ($) {
if (typeof (window.localStorage) != "undefined") {
$.each($("input[type=text]"), function () {
localStorage.getItem($(this).attr("id")));
});
$("input[type=text]").on("change", function () {
localStorage.setItem($(this).attr("id"), $(this).val());
});
}
})(jQuery);
Run Code Online (Sandbox Code Playgroud)
但是我做不到这一点。