Discussion:
JDBC. Why this code hangs pc.
Andrius Vilciauskas
2002-12-02 12:29:16 UTC
Permalink
Hello,

I'm not very experienced in sapdb and java. I need explainaition why my code
hangs pc. Thanks in advance .
Three classes:

public class Database {
Connection connection;
public Database() {
try {
Class.forName("com.sap.dbtech.jdbc.DriverSapDB");//
} catch (ClassNotFoundException e) {};
try{
connection = java.sql.DriverManager.getConnection ("jdbc:sapdb://" +
"andriusxp" + "/" + "erp_dev",
"dba", "dba");
} catch (SQLException e){
System.out.println(e.getMessage());
};
}
public Connection getConnection() {
return connection;
}

}

public class TableA {
Connection con;

public void setConnection(Connection conn) {
con = conn;
}

public void update() {
try {
Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,

ResultSet.CONCUR_UPDATABLE);
ResultSet rs = stmt.executeQuery("select * from erp_partners");
rs.next();
String hello = rs.getString(2);

rs.updateString(2, "AA"); // PROBLEM IS HERE
rs.updateRow();
System.out.println(hello);
}catch (SQLException e) {
System.out.println(e.getMessage());
}

}

}


public class Main {

public Main() {
Database db = new Database();
Connection conn = db.getConnection();
TableA a = new TableA();
a.setConnection(conn);
a.update();
System.out.println("End");
}

public static void main(String[] args) {
Main main = new Main();
}
}
Schroeder, Alexander
2002-12-02 12:40:29 UTC
Permalink
Hi Andrius,

there is nothing weird with the code ... it should work. However,
if this hangs this possibly means that the network connection hangs.

Try 'pinging' the machine 'andriusxp' from your client, and look
whether this takes long, or hangs. If yes, look into your network
configuration whether this is the case.

Perhaps you may be also a victim of a problem described before:

http://listserv.sap.com/pipermail/sapdb.general/2001-January/006388.html

Regards
Alexander Schröder
SAP Labs Berlin
-----Original Message-----
Sent: Monday, December 02, 2002 1:29 PM
Subject: JDBC. Why this code hangs pc.
Hello,
I'm not very experienced in sapdb and java. I need
explainaition why my code
hangs pc. Thanks in advance .
public class Database {
Connection connection;
public Database() {
try {
Class.forName("com.sap.dbtech.jdbc.DriverSapDB");//
} catch (ClassNotFoundException e) {};
try{
connection = java.sql.DriverManager.getConnection ("jdbc:sapdb://" +
"andriusxp" + "/" + "erp_dev",
"dba", "dba");
} catch (SQLException e){
System.out.println(e.getMessage());
};
}
public Connection getConnection() {
return connection;
}
}
public class TableA {
Connection con;
public void setConnection(Connection conn) {
con = conn;
}
public void update() {
try {
Statement stmt =
con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
ResultSet rs = stmt.executeQuery("select * from erp_partners");
rs.next();
String hello = rs.getString(2);
rs.updateString(2, "AA"); // PROBLEM IS HERE
rs.updateRow();
System.out.println(hello);
}catch (SQLException e) {
System.out.println(e.getMessage());
}
}
}
public class Main {
public Main() {
Database db = new Database();
Connection conn = db.getConnection();
TableA a = new TableA();
a.setConnection(conn);
a.update();
System.out.println("End");
}
public static void main(String[] args) {
Main main = new Main();
}
}
_______________________________________________
sapdb.general mailing list
http://listserv.sap.com/mailman/listinfo/sapdb.general
Andrius Vilciauskas
2002-12-02 14:05:36 UTC
Permalink
I run this code and sapdb on the same machine. I have changed host name to
localhost. Everything works good except updateXXX methods.
Watz
2002-12-02 20:38:03 UTC
Permalink
Hi,

the code looks ok to me.
If you're experiencing "hangs" on update or insert statements with whatever client make sure your database logs aren't full.
It seems to be a typical SAPDB behaviour to wait for enough transaction log space to be available when commiting data, this causes the client to "hang" (it will continue to run once theres log freed online).

This is especially a problem with rather tiny databases and very little log space (just a few MB for example). Keep an eye out for your log space if you have transaction logging switched on. If you don't need it set the databases logmode to "DEMO".

Hope this helps,

Watz
Post by Andrius Vilciauskas
Hello,
I'm not very experienced in sapdb and java. I need explainaition why my code
hangs pc. Thanks in advance .
public class Database {
Connection connection;
public Database() {
try {
Class.forName("com.sap.dbtech.jdbc.DriverSapDB");//
} catch (ClassNotFoundException e) {};
try{
connection = java.sql.DriverManager.getConnection ("jdbc:sapdb://" +
"andriusxp" + "/" + "erp_dev",
"dba", "dba");
} catch (SQLException e){
System.out.println(e.getMessage());
};
}
public Connection getConnection() {
return connection;
}
}
public class TableA {
Connection con;
public void setConnection(Connection conn) {
con = conn;
}
public void update() {
try {
Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
ResultSet rs = stmt.executeQuery("select * from erp_partners");
rs.next();
String hello = rs.getString(2);
rs.updateString(2, "AA"); // PROBLEM IS HERE
rs.updateRow();
System.out.println(hello);
}catch (SQLException e) {
System.out.println(e.getMessage());
}
}
}
public class Main {
public Main() {
Database db = new Database();
Connection conn = db.getConnection();
TableA a = new TableA();
a.setConnection(conn);
a.update();
System.out.println("End");
}
public static void main(String[] args) {
Main main = new Main();
}
}
_______________________________________________
sapdb.general mailing list
http://listserv.sap.com/mailman/listinfo/sapdb.general
Andrius Vilciauskas
2002-12-03 06:45:28 UTC
Permalink
Data usage 4%
Log usage 12%

Database is allmost empty.
Peng Tuck Kwok
2002-12-03 07:15:43 UTC
Permalink
What code? I don't see any code.
Post by Andrius Vilciauskas
Data usage 4%
Log usage 12%
Database is allmost empty.
_______________________________________________
sapdb.general mailing list
http://listserv.sap.com/mailman/listinfo/sapdb.general
Andrius Vilciauskas
2002-12-03 07:39:51 UTC
Permalink
Look at first post
Schroeder, Alexander
2002-12-03 08:36:47 UTC
Permalink
Hello Andrius,

there is a bug in the JDBC driver that occurs when updatable result set
is used together with a DEFAULT SERIAL column, and wich produces an endless
loop in the driver.

There is currently no work-around possible, except not using a DEFAULT SERIAL
column.

Thanks for reporting the issue, and sorry for any inconvenience.

Regards

Alexander Schröder
SAP Labs Berlin
-----Original Message-----
Sent: Tuesday, December 03, 2002 7:42 AM
To: Schroeder, Alexander
Subject: Re: JDBC. Why this code hangs pc.
Good morning Alexander,
I wasn't clear yesterday. The program stops responding on
rs.updateString
CREATE TABLE "DBA"."ERP_PARTNERS"
(
"ID" Fixed (10,0) DEFAULT SERIAL (1),
"CLIENT" Varchar (70) ASCII,
"COUNTRY_ID" Fixed (10,0),
"INCOTERM" Char (3) ASCII,
PRIMARY KEY ("ID")
)
Data usage 4%, log usage 12%. I'm the only user of db at
current moment.
I have tried select ... from lockstatistics - no result.
I use java sdk 1.41. on WinxpSP1.
SAPdb version 7.3.0.29 and jdbc driver that you have sent a
month or two
ago.
Can you confirm me that code snipet I have sent works on your pc.
Sven Köhler
2002-12-03 09:26:59 UTC
Permalink
Post by Schroeder, Alexander
there is a bug in the JDBC driver that occurs when updatable result set
is used together with a DEFAULT SERIAL column, and wich produces an endless
loop in the driver.
There is currently no work-around possible, except not using a DEFAULT SERIAL
column.
That makes me sad because i was going to use exactly that in a few days.

When will there be an updated JDBC-driver?

Loading...