rameshfaj Posted July 4, 2007 Share Posted July 4, 2007 I am new to Oracle. What i need is to connect Oracle from JAVA.I am using windowsXP as O.S.What should I do plz explain to me. Quote Link to comment https://forums.phpfreaks.com/topic/58375-java-and-oracle-connectivity/ Share on other sites More sharing options...
gizmola Posted July 4, 2007 Share Posted July 4, 2007 You need the Oracle jdbc driver. This sample code sums it up pretty simply I think: Connection connection = null; try { // Load the JDBC driver String driverName = "oracle.jdbc.driver.OracleDriver"; Class.forName(driverName); // Create a connection to the database String serverName = "127.0.0.1"; String portNumber = "1521"; String sid = "mydatabase"; String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber + ":" + sid; String username = "username"; String password = "password"; connection = DriverManager.getConnection(url, username, password); } catch (ClassNotFoundException e) { // Could not find the database driver } catch (SQLException e) { // Could not connect to the database } Quote Link to comment https://forums.phpfreaks.com/topic/58375-java-and-oracle-connectivity/#findComment-289878 Share on other sites More sharing options...
rameshfaj Posted July 5, 2007 Author Share Posted July 5, 2007 THanks for the suggestion. Do i need a separate connector along with the server as in mysql? If so how to get it and set the path for it plz explain. Quote Link to comment https://forums.phpfreaks.com/topic/58375-java-and-oracle-connectivity/#findComment-290090 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.