我有这个问题,REPLACE功能不适用于eclipselink版本2.5.2.
这是我的代码:
String sSql = " SELECT e FROM br.com.megasoft.protocolo.entity.Assunto e WHERE ( REPLACE(REPLACE(REPLACE( UPPER(e.titulo), '/', ''), '-', ''), '.', '') LIKE UPPER('A') )";
TypedQuery<?> query = getEntityManager().createQuery(sSql, Class.forName(this.tabela));
Run Code Online (Sandbox Code Playgroud)
第二个参数的值为: class br.com.megasoft.protocolo.entity.Assunto
它给出了这个例外:
Caused by: Exception [EclipseLink-0] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.JPQLException
Exception Description: Syntax error parsing [ FROM br.com.megasoft.protocolo.entity.Assunto e WHERE ( REPLACE(REPLACE(REPLACE( UPPER(e.titulo), '/', ''), '-', ''), '.', '') LIKE UPPER( :valorPesq10) ) ].
[54, 150] The expression is not a valid conditional expression.
at …Run Code Online (Sandbox Code Playgroud) 我想通过使用HttpURLConnection进行POST.我在两个方面尝试这个,但在做的时候我总是得到一个例外:conn.getOutputStream();
我在两种情况下得到的例外是:
java.net.SocketException:操作超时:connect:可能是由于地址无效
功能1:
public void makePost(String title, String comment, File file) {
try {
URL servlet = new URL("http://" + "www.server.com/daten/web/test/testupload.nsf/upload?CreateDocument");
HttpURLConnection conn=(HttpURLConnection)servlet.openConnection();
conn.setDoOutput(true);
conn.setDoInput(true);
conn.setUseCaches(false);
String boundary = "---------------------------7d226f700d0";
conn.setRequestProperty("Content-type","multipart/form-data; boundary=" + boundary);
//conn.setRequestProperty("Referer", "http://127.0.0.1/index.jsp");
conn.setRequestProperty("Cache-Control", "no-cache");
OutputStream os = conn.getOutputStream(); //exception throws here!
DataOutputStream out = new DataOutputStream(os);
out.writeBytes("--" + boundary + "\r\n");
writeParam(INPUT_TITLE, title, out, boundary);
writeParam(INPUT_COMMENT, comment, out, boundary);
writeFile(INPUT_FILE, file.getName(), out, boundary);
out.flush();
out.close();
InputStream stream = conn.getInputStream();
BufferedInputStream in = new BufferedInputStream(stream); …Run Code Online (Sandbox Code Playgroud) 我在从MySql数据库中获取数据时遇到问题.我的代码如下:
try {
Connection con = datasource.getConnection();
Statement stmt = con.createStatement();
ResultSet rs;
rs = stmt.executeQuery("SELECT tittle,date,path " +
"FROM announcement "+
"ORDER BY date");
String tittle=rs.getString("tittle");
String date=rs.getString("date");
String text=rs.getString("path");
if (!rs.isBeforeFirst())
{
out.println("<p>No data !</p>");
}
else
{
out.println("<table class=\"data\">");
out.println("<tr ><td class=\"sectionheader\"> tittle?</td><td class=\"sectionheader\">date</td><td class=\"sectionheader\">text</td></tr>");
while (rs.next()) {
String row="";
row += "<td><a href=\"\"> "+tittle+ "</td>";
row += "<td>" + date + "</td>";
row +="<td>"+text+"</td>";
row +="</tr>";
out.println(row);
}
Run Code Online (Sandbox Code Playgroud)
我得到的错误是"java.sql.SQLException: Before start of result …
我想要一个添加ToolTip到自定义MapMarker的JMapViewer。但是,取消搜索并不能帮助我解决这个问题。
自定义MapMarker为:
public class MapMarkerUnit extends MapObjectImpl implements MapMarker
Run Code Online (Sandbox Code Playgroud)
绘制方法的覆盖是
public void paint(Graphics g, Point position, int radio) {
String filename = "marker.png";
//System.out.print(filename);
BufferedImage x = null;
try {
x = ImageIO.read(getClass().getResource(filename));
} catch (IOException ex) {
Logger.getLogger(MapMarkerUnit.class.getName()).log(Level.SEVERE, null, ex);
}
g.drawImage(x, position.x-16, position.y-37,null);
//if(getLayer()==null||getLayer().isVisibleTexts()) paintText(g, new Point(position.x+20,position.y));
}
Run Code Online (Sandbox Code Playgroud)
感谢您提供的任何帮助。
嗯,我找不到错误:
package udemy;
public class ClassOne {
private int positiveNum;
public ClassOne (int positiveNum){
if (positiveNum< 0 ){
throw new IllegalArgumentException("positiveNum should be greater than 0");
}
this.positiveNum= positiveNum;
}
public int getNum(){
return positiveNum;
}
}
Run Code Online (Sandbox Code Playgroud)
在我的主要课程中,我得到了这段代码:
package udemy;
public class ClassTwo {
public static void main (String[] args) {
ClassOne number= new ClassOne(-15);
try {
System.out.printf("%s%n",number.getNum());
}
catch(IllegalArgumentException e)
{
System.out.printf("%s",e.getMessage());
}
}
}
Run Code Online (Sandbox Code Playgroud)
但我得到以下输出:
Exception in thread "main" java.lang.IllegalArgumentException:positiveNum should be greater than 0
at udemy.ClassOne.<init>(ClassOne.java:11)
at …Run Code Online (Sandbox Code Playgroud)