Reputation: 449
Could someone tell me exactly how could I manage this connection? I am doing this for like 3 days now and every example, every video on the net is about MySQL or SQLite connection with NetBeans. My goal is to put the results of a SELECT query in a JTable. Nothing more. I know I need some driver and connection URL, ResultSet, PreparedStatement, TableModel, but I didn't manage to find the perfect combination to get some results.
Thanks.
Upvotes: 6
Views: 26177
Reputation: 1284
You may be struggling with all the options on the IntelliJ dialog. Most IDEs provide a way to specify the JDBC URL. If you are familiar with Oracle TNS names the below URLs will work for you when you have a complex Oracle address list (as in RAC, for instance) or when there is a firewall and you must specify SERVER=DEDICATED
:
jdbc:oracle:thin:@(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = yourdbhost.com)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = XE)))
or
jdbc:oracle:thin:@(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = yourdbhost.com)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SID = XE)))
In most simple cases this will suffice:
jdbc:oracle:thin:@yourdbhost.com:1521:XE
Finally, make sure your username and password work by testing them with SQL/PLUS
Upvotes: 1
Reputation: 718758
If you can't find a tutorial or video that covers all of this, then you need to combine sources that cover the individual parts of the problem.
For example:
This covers configuring data sources in IntelliJ 14: https://www.jetbrains.com/idea/help/configuring-a-db-data-source.html
This covers JDBC database URLs for Oracle databases: http://docs.oracle.com/cd/B14117_01/java.101/b10979/urls.htm#BEIJFHHB. And so does this: http://www.herongyang.com/JDBC/Oracle-JDBC-Driver-Connection-URL.html
The javadocs cover the various APIs you are using.
and so on.
Upvotes: 2