{"id":15522591,"url":"https://github.com/imranhsayed/programming-in-java","last_synced_at":"2026-02-07T06:33:49.875Z","repository":{"id":97032871,"uuid":"538089938","full_name":"imranhsayed/programming-in-java","owner":"imranhsayed","description":"Example programs in Java","archived":false,"fork":false,"pushed_at":"2022-10-12T05:26:16.000Z","size":30,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-03T12:06:29.072Z","etag":null,"topics":["python","python-examples","python-exercises"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/imranhsayed.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-09-18T11:38:49.000Z","updated_at":"2024-06-03T17:59:34.000Z","dependencies_parsed_at":"2024-03-09T03:00:51.440Z","dependency_job_id":null,"html_url":"https://github.com/imranhsayed/programming-in-java","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/imranhsayed/programming-in-java","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imranhsayed%2Fprogramming-in-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imranhsayed%2Fprogramming-in-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imranhsayed%2Fprogramming-in-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imranhsayed%2Fprogramming-in-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/imranhsayed","download_url":"https://codeload.github.com/imranhsayed/programming-in-java/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imranhsayed%2Fprogramming-in-java/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29188226,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-07T05:07:31.176Z","status":"ssl_error","status_checked_at":"2026-02-07T05:06:15.227Z","response_time":63,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["python","python-examples","python-exercises"],"created_at":"2024-10-02T10:41:39.361Z","updated_at":"2026-02-07T06:33:49.855Z","avatar_url":"https://github.com/imranhsayed.png","language":"Java","readme":"# programming-in-java\nExample programs in Java\n\n# What is ResultSet In Java?\n* ResultSet is an interface in Java that is used to get the database result in a table format. \n* The object of ResultSet maintains a cursor pointing to a row of a table. Initially, cursor points to before the first row.\n* But we can make this object to move forward and backward direction by passing either TYPE_SCROLL_INSENSITIVE or TYPE_SCROLL_SENSITIVE in createStatement(int,int) method as well as we can make this object as updatable by:\n```java\nStatement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,  \n                     ResultSet.CONCUR_UPDATABLE);  \n```\n* Example\n```java\nimport java.sql.*;  \nclass FetchRecord{  \npublic static void main(String args[])throws Exception{  \n  \nClass.forName(\"oracle.jdbc.driver.OracleDriver\");  \nConnection con=DriverManager.getConnection(\"jdbc:oracle:thin:@localhost:1521:xe\",\"system\",\"oracle\");  \nStatement stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);  \nResultSet rs=stmt.executeQuery(\"select * from emp765\");  \n  \n//getting the record of 3rd row  \nrs.absolute(3);  \nSystem.out.println(rs.getString(1)+\" \"+rs.getString(2)+\" \"+rs.getString(3));  \n  \ncon.close();  \n}}  \n```\n\n* Another example\n\n\n```java\n/STEP 1. Import required packages\nimport java.sql.*;\n\npublic class Main{\n   // JDBC driver name and database URL\n   static final String JDBC_DRIVER = \"com.mysql.jdbc.Driver\";  \n   static final String DB_URL = \"jdbc:mysql://localhost/STUDENTS\";\n\n   //  Database credentials\n   static final String USER = \"username\";\n   static final String PASS = \"password\";\n   \n   public static void main(String[] args) {\n   Connection conn = null;\n   Statement stmt = null;\n   try{\n      //STEP 2: Register JDBC driver\n      Class.forName(\"com.mysql.jdbc.Driver\");\n\n      //STEP 3: Open a connection\n      System.out.println(\"Connecting to a selected database...\");\n      conn = DriverManager.getConnection(DB_URL, USER, PASS);\n      System.out.println(\"Connected database successfully...\");\n      \n      //STEP 4: Execute a query\n      System.out.println(\"Creating statement...\");\n      stmt = conn.createStatement();\n\n      String sql = \"SELECT id, first, last, age FROM Registration\";\n      ResultSet rs = stmt.executeQuery(sql);\n      //STEP 5: Extract data from result set\n      while(rs.next()){\n         //Retrieve by column name\n         int id  = rs.getInt(\"id\");\n         int age = rs.getInt(\"age\");\n         String first = rs.getString(\"first\");\n         String last = rs.getString(\"last\");\n\n         //Display values\n         System.out.print(\"ID: \" + id);\n         System.out.print(\", Age: \" + age);\n         System.out.print(\", First: \" + first);\n         System.out.println(\", Last: \" + last);\n      }\n      rs.close();\n   }catch(SQLException se){\n      //Handle errors for JDBC\n      se.printStackTrace();\n   }catch(Exception e){\n      //Handle errors for Class.forName\n      e.printStackTrace();\n   }finally{\n      //finally block used to close resources\n      try{\n         if(stmt!=null)\n            conn.close();\n      }catch(SQLException se){\n      }// do nothing\n      try{\n         if(conn!=null)\n            conn.close();\n      }catch(SQLException se){\n         se.printStackTrace();\n      }//end finally try\n   }//end try\n   System.out.println(\"Goodbye!\");\n}//end main\n}//end Class\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimranhsayed%2Fprogramming-in-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimranhsayed%2Fprogramming-in-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimranhsayed%2Fprogramming-in-java/lists"}