This commit is contained in:
2026-03-05 15:26:55 +05:30
parent 3835bad178
commit 248e1fdd95
28 changed files with 300 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-21">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src"/>
<classpathentry kind="lib" path="C:/Users/Admin/Downloads/mysql-connector-j-9.6.0/mysql-connector-j-9.6.0/mysql-connector-j-9.6.0.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -0,0 +1 @@
/bin/

View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>prg5_b2_38</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
<filteredResources>
<filter>
<id>1772701019096</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>

View File

@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8

View File

@@ -0,0 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=21
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=21
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=21

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

View File

@@ -0,0 +1,65 @@
package in.test;
import java.sql.*;
public class jdbcscrollresultdemo {
static final String JDBC_DRIVER = "com.mysql.cj.jdbc.Driver";
static final String DB_URL = "jdbc:mysql://localhost:3306/jdbc_B2_38";
static final String USERNAME="root";
static final String PASSWORD = "12345";
public static void main(String[] args) {
jdbcscrollresultdemo jdbcscrollresultset = new jdbcscrollresultdemo();
jdbcscrollresultset.getstudentinfo();
}
private void getstudentinfo(){
Connection con = null;
PreparedStatement preparedStatement = null;
try{
Class.forName(JDBC_DRIVER);
con = DriverManager.getConnection(DB_URL, USERNAME, PASSWORD);
String sql = "select * from student";
preparedStatement = con.prepareStatement(sql, ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
ResultSet rs = preparedStatement.executeQuery();
System.out.println("ResultSet move forward");
while (rs.next()) {
int rn = rs.getInt("Rollno");
String name = rs.getString("Name");
System.out.println("Rollno" + rn);
System.out.println("Name" + name);
}
System.out.println("at particular position");
rs.absolute(2);
int id = rs.getInt(1);
String name = rs.getString(2);
System.out.println("Rollno: " + id);
System.out.println("Name: " + name);
rs.close();
}
catch(SQLException se){
se.printStackTrace();
}
catch(ClassNotFoundException e){
e.printStackTrace();
}
finally{
try{
if (preparedStatement!=null) {
preparedStatement.close();
}
}
catch(SQLException sqlException){
sqlException.printStackTrace();
}
try{
if(con!=null){
con.close();
}
}
catch(SQLException sqlException){
sqlException.printStackTrace();
}
}
}
}