[#|2017-03-16T11:11:28.612+0200|SEVERE|glassfish
4.1|com.mrkcn.servlet.LoginServ
let|_ThreadID=26;_ThreadName=http-listener-1(2);_TimeMillis=1489655488612;_Level
Value=1000;|
com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near '#P2'.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError
(SQLServerException.java:216)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServ
erStatement.java:1515)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePrep
aredStatement(SQLServerPreparedStatement.java:404)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecC
md.doExecute(SQLServerPreparedStatement.java:350)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:5696)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLSe
rverConnection.java:1715)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLSer
verStatement.java:180)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLS
erverStatement.java:155)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeQuery(
SQLServerPreparedStatement.java:285)
at com.mrkcn.servlet.KonularServlet.doGet(KonularServlet.java:53)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java
:1682)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:318)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:160)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.j
ava:734)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:673)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:174)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.j
ava:416)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:283)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallab
le.call(ContainerMapper.java:459)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(Container
Mapper.java:167)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.
java:206)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.ja
va:180)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpSer
verFilter.java:235)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(Executor
Resolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(De
faultFilterChain.java:283)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart
(DefaultFilterChain.java:200)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultF
ilterChain.java:132)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultF
ilterChain.java:111)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.jav
a:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNI
OTransport.java:536)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(Abstr
actIOStrategy.java:112)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerTh
readIOStrategy.java:117)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(Wo
rkerThreadIOStrategy.java:56)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadR
unnable.run(WorkerThreadIOStrategy.java:137)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(Abs
tractThreadPool.java:591)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(Abstra
ctThreadPool.java:571)
at java.lang.Thread.run(Thread.java:745)
|#]
I am using java netbeans web service. Mssql gives error during den select command. What can be the problem ?
There is no trouble in another question. Did I put the question marks at the wrong place? No problem with sql as seen from sql management
String uye = req.getParameter("uye");
JSONObject j = new JSONObject();
ArrayList<String> konularList = new ArrayList<String>(100);
ConnectInfo connect = new ConnectInfo();
Connection con;
PreparedStatement pstmt;
ResultSet rs;
PrintWriter out = resp.getWriter();
con=connect.baglanti();
String Sorgu = "select t.id,t.uye,t.baslik,t.mesaj,t.kategori,format(t.tarih, 'dd.MM.yyyy HH:mm') as tarih,t.edittarih,t.aktif,t.indirimpuani,t.altkategori,t.link, isnull((select case when t.id = f.konuid and f.uye = ? then '1' else '0' end from takipkonu f where t.id = f.konuid and f.uye = ?),'0') as takip from konular t ?";
pstmt=con.prepareStatement(Sorgu);
pstmt.setString(1,uye);
pstmt.setString(2,uye);
pstmt.setString(3,"order by t.tarih");
rs=pstmt.executeQuery();
while(rs.next())
{
j.put("id", rs.getInt("id"));
j.put("uye",rs.getString("uye"));
j.put("baslik", rs.getString("baslik"));
j.put("mesaj", rs.getString("mesaj"));
j.put("kategori", rs.getString("kategori"));
j.put("altkategori", rs.getString("altkategori"));
j.put("tarih", rs.getString("tarih"));
j.put("edittarih", rs.getString("edittarih"));
j.put("aktif", rs.getInt("aktif"));
j.put("indirimpuani", rs.getInt("indirimpuani"));
j.put("link", rs.getString("link"));
j.put("takip", rs.getString("takip"));
konularList.add(j.toString());
}
Related
I have used Hibernate 4 since a long time and now I need to upgrade to hibernate 5 and I have some trouble now with some named query:
ERROR: HHH000177: Error in named query: findByNumHeure
org.hibernate.hql.internal.ast.QuerySyntaxException: Unable to locate appropriate constructor on class [ch.plugin.plugin.entity.Reservation]. Expected arguments are: ch.plugin.plugin.entity.Reservation, long [SELECT new Reservation(r, COUNT(r.numeroReservation)) FROM ch.plugin.plugin.entity.Reservation r WHERE r.numeroReservation =:num and r.reservationPK.heureDebutReservation = :heure GROUP BY r.numeroReservation HAVING r.reservationPK.heureDebutReservation = min(r.reservationPK.heureDebutReservation)]
and this is my named query:
#NamedQuery(name = "findByNumHeure", query = "SELECT new Reservation(r, COUNT(r.numeroReservation)) FROM Reservation r WHERE r.numeroReservation =:num and r.reservationPK.heureDebutReservation = :heure GROUP BY r.numeroReservation HAVING r.reservationPK.heureDebutReservation = min(r.reservationPK.heureDebutReservation)"),
and of course, I have this constructor:
public Reservation() {
}
public Reservation(Reservation reservation, Long etat) {
this.reservationPK = reservation.getReservationPK();
this.couleurReservation = reservation.getCouleurReservation();
this.iDRecurrence = reservation.getIDRecurrence();
this.isPaye = reservation.getIsPaye();
this.numeroReservation = reservation.getNumeroReservation();
this.responsable = reservation.getResponsable();
this.texte = reservation.getTexte();
this.etat = etat.intValue();
this.prix = reservation.getPrix();
}
So my question is: Why it was working well in Hibernate 4 and now this is not working any more with Hibernate 5? And the code is exactly the same?
Query is getting executed well but problm with JPA .Please help me to find the wrongness.
Query works well if I execute seperately in Oracle SQL client but with application gives error.
Am getting exception in this line as Eclipse says
return genDODetails(pSess.executeQuery(rq));
Query :
SELECT DOD.ID AS DODID,ORDD.ID AS ORDDID,DOD.SHIPQTY AS DOQTY,DOD.BUYERCODE AS BUYERCODE,DOD.BUYERPARTNUM AS BUYERPARTNUM,
DOD.BUYERPARTDESC AS BUYERPARTDESC,DOD.LINENUM AS DOLINENUM,DOD.LINEREVNUM AS LINEREVNUM,
DOD.LINEINDICATIOR AS LINEINDICATOR,DOD.ORDLINENUM AS ORDLINENUM,ORDD.SHIPQTY AS SHIPPEDQTY,
DOD.RSPREMARK1 AS SUPREMARK,DOD.ORDNUM AS PONUM
FROM RDT_DELIVERYORDERDETAIL DOD,RDT_ORDERDETAIL ORDD ,RDT_ORDER ORDM
WHERE ORDD.LATEST =1
AND ORDM.LATEST =1
AND ORDM.ID = ORDD.ORDID
AND ORDD.RESPSTR1 ='EP'
AND ORDD.LINENUM = DOD.ORDLINENUM
AND ORDM.DOCNUM = DOD.ORDNUM
AND DOD.LATEST =1
AND CONTROLLERID =(SELECT ID FROM RDT_ORGANIZATION WHERE OUCODE ='yes' AND PARENTID IS NULL)
AND DOD.DOID = 72
ORDER BY DODID DESC;
JPA Execution Code:
public List<DODetail> getDODetails(Map<String,Object> hparams) throws Exception
{
String sqlQuery= pSess.getSQLString4NamedQuery("DO_VIEW_DETAIL");
String doid = hparams.get("DOID")!=null ?(String)hparams.get("DOID"):"";
Hashtable<String,Object> dbparams=new Hashtable();
dbparams.put(":DOID",doid);
sqlQuery = (String)pSess.getParamQuery(sqlQuery, dbparams);
ReportQuery rq=new ReportQuery();
rq.setReferenceClass(DODetail.class);
rq.addAttribute("DODID");
rq.addAttribute("ORDDID");
rq.addAttribute("DOQTY");
rq.addAttribute("BUYERCODE");
rq.addAttribute("BUYERPARTNUM");
rq.addAttribute("BUYERPARTDESC");
rq.addAttribute("DOLINENUM");
rq.addAttribute("LINEREVNUM");
rq.addAttribute("LINEINDICATOR");
rq.addAttribute("ORDLINENUM");
rq.addAttribute("SHIPPEDQTY");
rq.addAttribute("SUPREMARK");
rq.addAttribute("PONUM");
rq.setSQLString(sqlQuery);
return genDODetails(pSess.executeQuery(rq));
}
private List<DODetail> genDODetails(Object obj)throws Exception
{
if(obj==null ) return null;
List newList = (List)obj;
Iterator it = newList.iterator();
List<DODetail> doDetails = new ArrayList<DODetail>();
while(it.hasNext())
{
ReportQueryResult rs=(ReportQueryResult)it.next();
DODetail order=new DODetail();
order.setId(rs.get("DODID")!=null?((BigDecimal)rs.get("DODID")).longValue():new Long(0));
order.setRefid(rs.get("ORDDID")!=null?((BigDecimal)rs.get("ORDDID")).longValue():new Long(0));
order.setShipqty(rs.get("DOQTY")!=null?(BigDecimal)rs.get("DOQTY"):new BigDecimal(0));
order.setBuyercode(rs.get("BUYERCODE")!=null?(String)rs.get("BUYERCODE"):"");
order.setBuyerpartnum(rs.get("BUYERPARTNUM")!=null?(String)rs.get("BUYERPARTNUM"):"");
order.setCategory(rs.get("BUYERPARTDESC")!=null?(String)rs.get("BUYERPARTDESC"):"");
order.setLinenum(rs.get("DOLINENUM")!=null?((BigDecimal)rs.get("DOLINENUM")).longValue():new Long(0));
order.setLinerevnum(rs.get("LINEREVNUM")!=null?(String)rs.get("LINEREVNUM"):"");
order.setLineindicator(rs.get("LINEINDICATOR")!=null?(String)rs.get("LINEINDICATOR"):"");
order.setOrdlinenum(rs.get("ORDLINENUM")!=null?((BigDecimal)rs.get("ORDLINENUM")).toPlainString():"");
order.setAssignqty(rs.get("SHIPPEDQTY")!=null?(BigDecimal)rs.get("SHIPPEDQTY"):new BigDecimal(0));
order.setRspremark1(rs.get("SUPREMARK")!=null?(String)rs.get("SUPREMARK"):"");
order.setOrdnum(rs.get("PONUM")!=null?(String)rs.get("PONUM"):"");
doDetails.add(order);
}
return doDetails;
}
Make sure, you didnt have a trailing semicolon in your query string, before execution.
Because, it is not needed, and it is one of the possible reasons for this error.
It is not required , when you send a query to the database using a OCI driver. Only when manually executing in SQL*Plus or something needs that as pushing the sql to the database engine for execution.
the website that im hosting off of is 000webhost.com
this is in the console that is the error,
java.net.MalformedURLException: no protocol: OxidePKz.net63.net/checkvote.php? username=oxide
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
and this is my check vote page code
<?php
$con = mysql_connect("mysql1.000webhost.com", "a5999082_oxidepk", "(put in right passcode)");
if (!$con) {
die("Could not connect to database: " . mysql_error());
}
mysql_select_db("DATABASE_NAME", $con);
$username = mysql_escape_string($_GET['username']);
if (isset($_GET['username'])) {
$result = mysql_query("SELECT * FROM `votes` where username = '$username'") or die(mysql_error());
$row = mysql_fetch_array($result);
if($row['username'] == $username) {
mysql_query("DELETE FROM `votes` where username = '$username'");
echo "true";
} else {
echo "false";
}
}
i made a my admin php thing with the table name votes
and this is the call back page
$rspscoding = gethostbyname("http://www.oxidepkz.net63.net");
if($_SERVER['REMOTE_ADDR'] == $rspscoding) {
$con = mysql_connect("mysql1.000webhost.com", "a5999082_oxidepk", "(put in right passcode)");
if (!$con) {
die("Could not connect to database: " . mysql_error());
}
mysql_select_db("DATABASE_NAME", $con);
$username = mysql_escape_string($_GET['username']);
if (isset($_GET['username'])) {
mysql_query("INSERT INTO `votes` (username) VALUES ('$username')") or die(mysql_error());
}
mysql_close($con);
}
A few things;
I'm wonderinhg why you are getting back a java exception from a php application
Next gethostbyname("http://www.oxidepkz.net63.vote.html") does NOT take a URL, it takes a hostname like "www.oxidepkz.net63.com" for example according to: http://php.net/manual/en/function.gethostbyname.php
Finally, your URL is malformed since there is no ending slash after the domain name.
"http://www.oxidepkz.net63.vote.html" will not work in any browser
Did it get truncated, perhaps?
I have followed the instructions provided in this website from content 5.3 and the code works fine.
My plan is to make a jar file (containing an interface/GUI), distribute that jar file to users, and then have them all read/write data should be from one excel file. When I place the excel file in local drive it works, but when I place the file in network folder/server, the java creates a problem:
java.exe has encountered a problem and needs to close. We are sorry
for the inconvenience.
or
Java Result: -1073741811
Any suggestions? Thank you
public class TestIntoExcel
{
public String s;
public double number;
public Date d;
public void display()throws ClassNotFoundException, SQLException
{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection writeConnection = DriverManager.getConnection
("jdbc:odbc:usersavedataODBC");
writeConnection.setReadOnly(false);
Statement writeStatement = writeConnection.createStatement();
writeStatement.executeUpdate("CREATE TABLE TEST_INSERT(COL1 INT,COL2 VARCHAR(10),COL3 DATE)");
PreparedStatement writeStatement2 =
writeConnection.prepareStatement("INSERT INTO TEST_INSERT(COL1,COL2,COL3)VALUES(?,?,?)");
for(int i = 0; i<3;i++)
{
writeStatement2.setDouble(1, i);
writeStatement2.setString(2, "Row" + i);
writeStatement2.setDate(3, new java.sql.Date(new Date().getTime()));
writeStatement2.execute();
}
String query = "select *from[TEST_INSERT]";
ResultSet rset = writeStatement.executeQuery(query);
//System.out.println(rset);
while(rset.next())
{
number = rset.getDouble("COL1");
s = rset.getString("COL2");
d = rset.getDate("COL3");
System.out.println(number+"\n"+s+"\n"+d);
}
writeStatement.close();
writeStatement2.close();
writeConnection.close();
I've optimized my DB2-query with a WITH-clause. Now it is fast, but does not work under JDBC anymore. Does anyone has an idea? Thanks!
WITH tmp AS (SELECT ID_EINSENDUNG, BEURTEILUNG, VERSANDDAT_BVD, LASTUSER
FROM BVDT.TEINSENDUNG_BVD WHERE VERSANDDAT_BVD =
'2008-02-26' --HOST VARIABLE 1
)
SELECT ID_EINSENDUNG, VERSANDDAT_BVD FROM tmp WHERE ID_EINSENDUNG >
4100 --HOST VARIABLE 2
Error Message: ERRORCODE=-4461, SQLSTATE=42815 SQLState: 42815
ErrorCode: -4461
Java Code:
public DBCursor searchViewLandwirtOhrmarke() throws Exception {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("WITH tmp AS " +
"(SELECT ID_EINSENDUNG, BEURTEILUNG, VERSANDDAT_BVD, LASTUSER FROM BVDT.TEINSENDUNG_BVD WHERE VERSANDDAT_BVD = ?) " +
"SELECT ID_EINSENDUNG, VERSANDDAT_BVD FROM tmp WHERE ID_EINSENDUNG > ?");
prepareStatement(stringBuilder.toString());
ps.setDate(1, DateUtils.getSQLDate("26.02.2008"));
ps.setInt(2,new Integer(4100));
executeCursorSelect();
return this;
}
public EinsendungBvd nextViewLandwirtOhrmarke() throws Exception {
if (endFetch()) {
return null;
}
EinsendungBvd result = new EinsendungBvd(dbConn);
result.setId_einsendung(new Integer(rs.getInt(1)));
if (rs.wasNull()) {
result.setId_einsendung(null);
}
result.setVersanddat_bvd(rs.getDate(11));
return result;
}
Looks like a date format problem to me. Try changing your date in ps.setDate(1, DateUtils.getSQLDate("26.02.2008")); to ps.setDate(1, DateUtils.getSQLDate("2008-02-26"));. I don't know the DateUtil specs, so this is just a wild guess.. (see here for a list of SQLSTATE/ERRORCODES)
Looking at IBM DB2 LUW version 9.7 Error codes issued by the IBM Data Server Driver for JDBC and SQLJ for error code -4461:
-4461 text-from-getMessage 42815
Explanation: The specified value is invalid or out of range.
User response: Call SQLException.getMessage to retrieve specific information about the problem.
Things to try:
Log the value of SQLException.getMessage().
Verify the data types for VERSANDDAT_BVD and ID_EINSENDUNG.
Test the query with one parameter at a time; isolate which parameter is the violator.
Verify DateUtils.getSQLDate() is parsing your date string correctly; compare the result of Date.getTime() on the Date from DateUtils.getSQLDate()and the Date from SimpleDateFormat.parse().