Visualizzazione dei risultati da 1 a 4 su 4
  1. #1

    jdbc ho una tabella con un nome contenente uno spazio

    Salve, spero di ricevere informazioni utili. ho questo codice:
    import java.sql.*;
    public class nuovariga{
    public static void main(String [] args) {
    Connection con = null;

    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    con = DriverManager.getConnection("jdbcdbc:Salerno");

    Statement st = con.createStatement
    (ResultSet.TYPE_SCROLL_INSENSITIVE ,
    ResultSet.CONCUR_UPDATABLE);
    // insert 3 rows

    ResultSet rs =
    st.executeQuery(" SELECT * FROM INPUTINCIDENTI");
    int nr = rs.getRow();
    rs.absolute(nr);
    //rs.moveToInsertRow();
    rs.last();
    rs.next();
    rs.moveToInsertRow();
    rs.updateInt("ID",(int) 271);
    rs.updateString("18","1");
    rs.insertRow();
    rs.moveToCurrentRow();


    st.close();
    con.close();

    } catch (Exception e) {
    System.err.println("Exception: "+e.getMessage());
    }
    }
    }
    funziona perfettamente, soltanto che il nome vero della tabella sarebbe INPUT INCIDENTI.
    Come posso fare, mi hanno richiesto di non toccare il database. Vi ringrazio infinitamente e in anticipo.

  2. #2
    è contro qualsiasi standard mettere il nome di una tabella con uno spazio.
    cmq prova a circondare il nome con le parentesi quadre.

  3. #3
    Utente di HTML.it L'avatar di Pastore12
    Registrato dal
    Oct 2008
    Messaggi
    1,051
    Primo tentativo con google (per oracle)
    Using table names with spaces is a very bad idea. But if you have to:

    SELECT * FROM "table with spaces"

    But if you quote the name with double quotes, the name will be case sensitiv!!!!! so "Table With Spaces" is different to "table with spaces"
    "Ethics are to me something private. Whenever you use it as an argument for why somebody_else should do something, you’re no longer being ethical, you’re just being a sanctimonious dick-head"
    Linus Torvalds

  4. #4
    Grazie infinite fermat. Con le parentesi quadre intorno al nome è andato alla perfezione. ho scritto [INPUT INCIDENTI] e tutto è andato a posto. Grazie Grazie

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.