我正在尝试从Oracle 9i数据库中获取记录,其值为特定列的"FOO - BAR".
"FOO - BAR"条件值存在于表中,但是当我运行查询时,结果不会出现.
在打破了我的脑袋一段时间之后,我们发现这个名字的大小有所不同.
'FOO – BAR'
'FOO - BAR'
Run Code Online (Sandbox Code Playgroud)
这次我复制(通过SQLDeveloper)DB值并将值粘贴到Eclipse IDE中.我没有看到Eclipse的任何差异.当我从IDE运行查询时,令我惊讶的是它工作并且价值即将到来.
我将相同的类文件部署到我们的服务器(UX盒),然后又回到第1个方块 - 值不会到来.
我尝试将我的IDE的文件编码从默认(Cp1252)更改为UTF-8,现在一切都很好.
有人可以解释发生了什么吗?连字符的大小会随编码而变化吗?我们有三种不同的破折号吗?
'2009-12 Dec' should be converted to '31-DEC-2009'
'2010-09 Sep' should be converted to '30-SEP-2010'
'2010-02 Feb' should be converted to '28-FEB-2010'
'2008-02 Feb' should be converted to '29-FEB-2008'
Run Code Online (Sandbox Code Playgroud)
将在下拉列表中向用户显示2009-12 Dec,2008-02 Feb的值.用户无法选择DAY.
应将用户选择的值传递给数据库.但是数据库期望格式中的日期DD-MMM-YYYY.查询具有<= USER_DATE条件.因此,应自动选择月份的最后一天并将其传递到数据库.
Pl帮助我编写完成上述工作的功能.
static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM MMM");
public static String convertMapedToSqlFormat(final String maped) {
String convertedMaped = null;
//....
return convertedMaped;
}
@Test
public void testConvertMapedToSqlFormat() {
String[] mapedValues = { "2009-12 Dec", "2009-11 Nov", "2009-10 …Run Code Online (Sandbox Code Playgroud) 我间歇性地得到以下错误.
ERROR Exception occured while fetching the available subscriptions from the database - Could not roll back Hibernate transaction; nested exception is org.hibernate.TransactionException: JDBC rollback failed
org.springframework.transaction.TransactionSystemException: Could not roll back Hibernate transaction; nested exception is org.hibernate.TransactionException: JDBC rollback failed
Caused by: org.hibernate.TransactionException: JDBC rollback failed
at org.hibernate.transaction.JDBCTransaction.rollback(JDBCTransaction.java:204)
at org.springframework.orm.hibernate3.HibernateTransactionManager.doRollback(HibernateTransactionManager.java:676)
... 80 more
Caused by: java.sql.SQLException: No more data to read from socket
java.sql.SQLException: Closed Connection
ERROR org.hibernate.transaction.JDBCTransaction 17/11/2010 20:49:41 - JDBC rollback failed
java.sql.SQLException: Io exception: Broken pipe
ERROR …Run Code Online (Sandbox Code Playgroud) 问题陈述:
信息跨越多个存储库 - SAP,DB等.现在,当我搜索特定的东西时,我想从所有存储库中提取相关数据.(暂时,假设我能够以巨大的XML格式从所有这些存储库中提取数据.)
如何为我的搜索添加意义?
我正在寻找一个基于Java的解决方案.
Jena/Semantic-Web会帮助我吗?我可以在RDF中定义关系吗?
由于我对语义Web知之甚少,我试图了解它是否解决了我的问题.如果我错了,请纠正我.
我是JQuery的新手.
我正在尝试使用此处列出的功能.
在 mya=$("#list").getDataIDs(); // Get All IDs被列出了仅在当前视图的ID.但是我的网格是分页的.我如何获取所有ID?
这是我的代码:
$(document).ready(function () {
jQuery("#customer_list").jqGrid({
url:'jq_customer_list',
datatype: "json",
colNames:['Col1','Col2','Col3'],
colModel:[
{name:'Col1',index:'Col1', width:100},
{name:'Col2',index:'Col2', width:80},
{name:'Col3',index:'Col3', width:75},
],
rowNum:20,
rowList:[5,10,20],
mtype:"GET",
rownumber:true,
rownumWidth:40,
pager: $("#customer_list_pager"),
viewrecords: true,
gridview: true,
caption:"My Data",
height: '50%',
pagination:true
}).navGrid('#customer_list_pager', { search:true, del: false, add: false, edit: false,searchtext:"Search" },
{}, // default settings for edit
{}, // default settings for add
{}, // delete
{closeOnEscape: true, multipleSearch: true,
closeAfterSearch: true }, // search options
{} …Run Code Online (Sandbox Code Playgroud) 从servlet,我将请求转发到呈现FusionChart的JSP页面.但是我在加载图表时遇到了问题.JSP文件未检测到JavaScript文件.文件夹结构是:
axis
|
WebContent
|
WEB-INF
|
classes
|_ com
|_FusionCharts.js
|_MyChartJsp.jsp
|_Line.swf
Run Code Online (Sandbox Code Playgroud)
和JSP代码:
<html>
<head>
<script language="text/javascript" src="/WEB-INF/classes/FusionCharts.js"></script>
</head>
<body bgcolor="#ffffff">
<div id="chartdiv" align="left">The chart will appear within
this DIV. This text will be replaced by the chart.</div>
<script type="text/javascript">
var foo = //value fetched from DAO
var myChart = new FusionCharts("/WEB-INF/classes/Line.swf",
"myChartId", "1000", "500");
myChart
.setDataXML("<graph caption='aCaption' xAxisName='xAxis' yAxisName='yAxis' showNames='1' decimalPrecision='0' formatNumberScale='0'>"+foo+"</graph>");
myChart.render("chartdiv");
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
用于转发请求的Servlet代码:
final RequestDispatcher requestDispatcher = request.getRequestDispatcher("/WEB-INF/classes/MyChartJsp.jsp");
requestDispatcher.forward(request, response);
Run Code Online (Sandbox Code Playgroud)
请求将转发到JSP.但是图表没有显示,因为它无法弄清楚FusionCharts …
public static String removeChar(String s, char c) {
StringBuffer r = new StringBuffer( s.length() );
r.setLength( s.length() );
int current = 0;
for (int i = 0; i < s.length(); i ++) {
char cur = s.charAt(i);
if (cur != c) r.setCharAt( current++, cur );
}
return r.toString();
}
Run Code Online (Sandbox Code Playgroud)
我在这里找到了上面的代码.
两个问题:
为什么我们需要做setLength()?没有它我得到java.lang.StringIndexOutOfBoundsException:字符串索引超出范围:0
当我用参数 - "teeter"和"e"运行这个程序时,'ttr'和三个垃圾字符即将到来.如何删除缓冲区中未使用的空格?
String url = getUrl();
try{
Connection con = getConnection(url, username, pwd);
}catch(ConnectionException e){
cleanUpUrl(url);
url = getUrl();
con = getConnection(url, username, pwd);
}
Run Code Online (Sandbox Code Playgroud)
我要做上面的事情.如果我没有获得一个URL的连接,那么我将尝试使用另一个URL.同样有10URL我要一个接一个地尝试.
我将如何递归地编写方法?
getUrl()具有读取属性文件的逻辑,并为您提供10个随机URL.
cleanUpUrl(url)与设置URL的到期时间有关,如果URL无效,将设置某些属性等.
编辑:对不起我想我错过了什么.递归,因为我已经做了方法调用,直到(我得到连接)或(所有的URL都无效并抛出了不同的异常).循环10次可能没有用,因为getUrl()的随机逻辑可能会多次选择相同的URL.
以下是否有意义?
Connection con = null;
do{
String url = getUrl();
try{
Connection con = getConnection(url, username, pwd);
}catch(ConnectionException e){
cleanUpUrl(url);
continue;
}catch(Exception e){
return null;
}
}while(con !=null);
Run Code Online (Sandbox Code Playgroud)
当所有网址都无效时,getUrl()将抛出异常.
class PhotoController {
def index = {
def baseFolder = grailsAttributes.getApplicationContext().getResource("/").getFile().toString()
def imagesFolder = baseFolder + '/images/sps'
def imageList1 = new File(imagesFolder).list()
[imageList:imageList1]
}
}
Run Code Online (Sandbox Code Playgroud)
以上列出了非jpg文件.我怎么能避免这种情况?!
public class CollectionsFilter {
public static void main(String[] args) {
List<Integer> list = Arrays.asList(new Integer[] { 1, 2, 3, 4, 5, 6, 7,
8, 9, 10 });
Collection<Integer> evenNumbers = Utils.filter(list,
new Predicate<Integer>() {
public boolean apply(Integer i) {
if (i % 2 == 0) {
return true;
}
return false;
}
});
Collection<Integer> oddNumbers = Utils.filter(list,
new Predicate<Integer>() {
public boolean apply(Integer i) {
if (i % 2 != 0) {
return true;
}
return false;
}
});
System.out.println("EVEN …Run Code Online (Sandbox Code Playgroud) java ×9
date ×1
date-format ×1
encoding ×1
fusioncharts ×1
generics ×1
grails ×1
groovy ×1
hibernate ×1
hyphen ×1
interface ×1
javascript ×1
jena ×1
jqgrid ×1
jquery ×1
jsp ×1
oop ×1
oracle ×1
recursion ×1
semantic-web ×1
spring ×1
sql ×1
sqlexception ×1
string ×1