문제

I can see the db file in the left pane of intellij but when I double click the file, nothing is opened. Also, I am on a trial of ultimate edition.

도움이 되었습니까?

해결책

An SQLite database is not a simple file that can be opened via a double click. To access a database, a Database driver needs to be defined to be used with the file. Here's how you can configure the database for use:

  1. Open the Database tool window (On the right side by default, or View> Tool Windows > Database)
  2. Use the add icon drop down to select SQLite and the driver you want to use enter image description here
  3. If this is the first time you have configured an SQLite database, you will need to configure the driver first.
    • Drivers can be defined globally, and then used by a database definition; or
    • Drivers can be defined per database definition.
    • Since you can define multiple global drivers (different versions for example), the first option is generally the best/easiest
  4. Expand the Drivers node in the left pane and drill down to the driver you are using
  5. You can either have IntelliJ IDEA download an appropriate driver JAR file, or you can define one using a jar in your file system. For example, I simply point to the JARs in my local Maven repository to define drivers. enter image description here
  6. Click the Apply button so that the newly defined driver will be available in the database configuration. enter image description here
  7. Navigate back to your SQLite configuration in the left pane
  8. By default, the Driver Files pane will now be collapsed. You can expand it if desired to see that it is using the global driver definition. Again, if desired, you could define a one off driver definition here.
  9. Select or enter the path to the SQLite database file
  10. Give the database a name
  11. Select if the database will have project or IDE (global) scope (i.e. availability)
  12. You can override the JDBC URL if needed, but the defaults – which gets populated once the driver and the database file are defined -- should work
  13. Set if the database should automatically sync (i.e. check for external changes) and if it should be read only. enter image description here
  14. Click Test Connection – you should get version information. enter image description here
  15. If desired, on the Schema & Tables tab you can set filters so only certain schema or tables are visible. You can also define the default schema. Click the Help button for more information
  16. Once you have the database defined, you can expand it in the database window and drill down
    • If you open the context menu (i.e. right click or the context menu key) on a table, you can open a table editor where you will see (and can edit) the tables content. (there’s also a edit table button in the database tool window’s tool bar)
    • On the context menu is also an option to open a console. You can enter SQL commands and then execute them (there is also a console button in the database tool window’s tool bar). IDEA does provide code completion for the database when editing SQL statements in the console or code.
    • Note that if any changes (especially structural changes) are made externally, and you did not select auto-sync in the configuration, you will need to re-sync the database to see those changes. There’s a sync button in the database tool window.
  17. The last thing you will want to do is go to Files > Settings > [Project Settings] > SQL Dialects and set the SQL dialect for the project to SQLite. This way IDEA will know which syntax to favor when doing code completion and error checking.
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top