<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[[Servlet] nn riesco a fare update SQL]]></title><description><![CDATA[<p dir="auto">Allora ho un metodo creaSQL() che crea una stringa SQL, stringa perfettamente funzionante perchè l'ho incollata direttamente nella finesta MySQL ed effettua l'upgrade:</p>
<pre><code>INSERT INTO q (id_u, id_q, id_d, p) VALUES(1, 4, 2, 1), (1, 4, 3, 2), (1, 4, 1, 3)
</code></pre>
<p dir="auto">Supponiamo quindi che quindi il metodo creaSQL sia così:</p>
<pre><code>protected String creaSQL(int id_usr) throws ClassNotFoundException, SQLException {
  String sql = "INSERT INTO q (id_u, id_q, id_d, p) VALUES(1, 4, 2, 1), (1, 4, 3, 2), (1, 4, 1, 3)";
  return sql;
}
</code></pre>
<p dir="auto">Fin qui sembrerebbe tutto ok, ora all'interno della servlet avrò un altro metodo che prende la stringa sql e la deve eseguire:</p>
<pre><code>protected String execQuery(int id_usr) throws ClassNotFoundException, SQLException {
        String msg="dentro";[COLOR=red]
        String sql = creaSQL(id_usr);
        Class.forName("com.mysql.jdbc.Driver");
        Connection conn = DriverManager.getConnection("url","user","pass");
        Statement st = conn.createStatement();
        int query = st.executeUpdate(sql);
                
        if (query==1) {
            msg = "OK..."; 
        } else {
            msg = "C'è stato un errore!!!";
        }
        //conn.close();[/COLOR]
        return msg;
    }
</code></pre>
<p dir="auto">Ma in return nn mi da nulla, manco "dentro". Se invece commento tutta la parte di codice in rosso, la parola "dentro" mi viene restituita.</p>
<p dir="auto">Dove sbaglio???</p>
]]></description><link>https://dev.connect.gt/topic/58643/servlet-nn-riesco-a-fare-update-sql</link><generator>RSS for Node</generator><lastBuildDate>Sat, 28 Nov 2026 11:59:42 GMT</lastBuildDate><atom:link href="https://dev.connect.gt/topic/58643.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 03 Jan 2008 13:53:37 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [Servlet] nn riesco a fare update SQL on Mon, 21 Jan 2008 08:53:41 GMT]]></title><description><![CDATA[<p dir="auto">Hai risolto il problema?<br />
Ma che tipo di Exception ti da? Controlla la console cosa ti indica.</p>
]]></description><link>https://dev.connect.gt/post/661500</link><guid isPermaLink="true">https://dev.connect.gt/post/661500</guid><dc:creator><![CDATA[valent]]></dc:creator><pubDate>Mon, 21 Jan 2008 08:53:41 GMT</pubDate></item><item><title><![CDATA[Reply to [Servlet] nn riesco a fare update SQL on Fri, 18 Jan 2008 18:45:44 GMT]]></title><description><![CDATA[<p dir="auto">Approfitterei per segnalare Hibernate ... è indubbiamente più tosto da apprendere e configurare ma ti dimentichi problemi di questo tipo</p>
]]></description><link>https://dev.connect.gt/post/661507</link><guid isPermaLink="true">https://dev.connect.gt/post/661507</guid><dc:creator><![CDATA[mister.jinx]]></dc:creator><pubDate>Fri, 18 Jan 2008 18:45:44 GMT</pubDate></item><item><title><![CDATA[Reply to [Servlet] nn riesco a fare update SQL on Tue, 08 Jan 2008 20:50:06 GMT]]></title><description><![CDATA[<p dir="auto">sicuro che id_usr abbia un valore  e non mandi in crash il metodo creaSQL?</p>
]]></description><link>https://dev.connect.gt/post/661501</link><guid isPermaLink="true">https://dev.connect.gt/post/661501</guid><dc:creator><![CDATA[legolas]]></dc:creator><pubDate>Tue, 08 Jan 2008 20:50:06 GMT</pubDate></item></channel></rss>