author | m2lahtel |
Tue, 10 Aug 2010 14:29:28 +0300 | |
changeset 3 | e7e0ae78773e |
parent 1 | b538b70cbe51 |
permissions | -rw-r--r-- |
1
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
1 |
// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
2 |
// All rights reserved. |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
3 |
// This component and the accompanying materials are made available |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
4 |
// under the terms of "Eclipse Public License v1.0" |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
5 |
// which accompanies this distribution, and is available |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html". |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
7 |
// |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
8 |
// Initial Contributors: |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
9 |
// Nokia Corporation - initial contribution. |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
10 |
// |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
11 |
// Contributors: |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
12 |
// |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
13 |
// Description: |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
14 |
// |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
15 |
|
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
16 |
#include <jni.h> |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
17 |
#include "DbmsStatement.h" |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
18 |
#include "DbmsConnection.h" |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
19 |
#include "DbmsResultSet.h" |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
20 |
#include "Utils.h" |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
21 |
#include "dbmsjni/com_symbian_dbms_jdbc_DbmsStatement.h" |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
22 |
#include <stdlib.h> |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
23 |
|
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
24 |
// // |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
25 |
// DbmsStatement peer |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
26 |
// // |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
27 |
|
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
28 |
DbmsStatement::DbmsStatement(DbmsConnection* aConnection){ |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
29 |
iConnection = aConnection; |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
30 |
} |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
31 |
|
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
32 |
DbmsStatement::~DbmsStatement(){ |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
33 |
} |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
34 |
|
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
35 |
void DbmsStatement::Close(){ |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
36 |
iView.Close(); |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
37 |
} |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
38 |
|
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
39 |
// // |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
40 |
// JNI |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
41 |
// // |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
42 |
|
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
43 |
/* |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
44 |
* Class: com_symbian_dbms_jdbc_DbmsStatement |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
45 |
* Method: _create |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
46 |
* Signature: (I)I |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
47 |
*/ |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
48 |
JNIEXPORT jint JNICALL Java_com_symbian_dbms_jdbc_DbmsStatement__1create |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
49 |
(JNIEnv *, jobject, jint aPeer){ |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
50 |
DbmsConnection* connection = (DbmsConnection*) aPeer; |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
51 |
DbmsStatement* statement = new DbmsStatement(connection); |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
52 |
return (jint) statement; |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
53 |
} |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
54 |
|
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
55 |
/* |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
56 |
* Class: com_symbian_dbms_jdbc_DbmsStatement |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
57 |
* Method: _executeUpdate |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
58 |
* Signature: (ILjava/lang/String;)I |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
59 |
*/ |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
60 |
JNIEXPORT jint JNICALL Java_com_symbian_dbms_jdbc_DbmsStatement__1executeUpdate |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
61 |
(JNIEnv *aEnv, jobject, jint aPeer, jstring aString){ |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
62 |
DbmsStatement* statement = (DbmsStatement*) aPeer; |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
63 |
RJString sql(*aEnv, aString); |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
64 |
RDbNamedDatabase& db = statement->iConnection->iDatabase; |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
65 |
TInt res = db.Execute(sql); |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
66 |
return res; |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
67 |
} |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
68 |
|
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
69 |
/* |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
70 |
* Class: com_symbian_dbms_jdbc_DbmsStatement |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
71 |
* Method: _executeQuery |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
72 |
* Signature: (ILjava/lang/String;)I |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
73 |
*/ |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
74 |
JNIEXPORT jint JNICALL Java_com_symbian_dbms_jdbc_DbmsStatement__1executeQuery |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
75 |
(JNIEnv *aEnv, jobject, jint aPeer, jstring aString){ |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
76 |
DbmsStatement* statement = (DbmsStatement*) aPeer; |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
77 |
RJString sql(*aEnv, aString); |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
78 |
TDbQuery query (sql); |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
79 |
TInt res = statement->iView.Prepare(statement->iConnection->iDatabase, query, RDbRowSet::EReadOnly); |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
80 |
if ( res < 0 ) { |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
81 |
return (jint) res; |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
82 |
} else { |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
83 |
res = statement->iView.EvaluateAll(); |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
84 |
if ( res < 0 ) { |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
85 |
return (jint) res; |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
86 |
} else { |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
87 |
DbmsResultSet* resultSet = new DbmsResultSet(statement); |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
88 |
return (jint) resultSet; |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
89 |
} |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
90 |
} |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
91 |
} |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
92 |
|
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
93 |
/* |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
94 |
* Class: com_symbian_dbms_jdbc_DbmsStatement |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
95 |
* Method: _close |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
96 |
* Signature: (I)V |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
97 |
*/ |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
98 |
JNIEXPORT void JNICALL Java_com_symbian_dbms_jdbc_DbmsStatement__1close |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
99 |
(JNIEnv *, jobject, jint aPeer){ |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
100 |
DbmsStatement* statement = (DbmsStatement*) aPeer; |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
101 |
statement->Close(); |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
102 |
delete statement; |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
103 |
} |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
104 |
|
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
105 |
/* |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
106 |
* Class: com_symbian_dbms_jdbc_DbmsStatement |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
107 |
* Method: _begin |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
108 |
* Signature: (I)V |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
109 |
*/ |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
110 |
JNIEXPORT jint JNICALL Java_com_symbian_dbms_jdbc_DbmsStatement__1begin |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
111 |
(JNIEnv *, jobject, jint aPeer) { |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
112 |
DbmsStatement* statement = (DbmsStatement*) aPeer; |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
113 |
return statement->iConnection->iDatabase.Begin(); |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
114 |
} |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
115 |
|
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
116 |
/* |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
117 |
* Class: com_symbian_dbms_jdbc_DbmsStatement |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
118 |
* Method: _commit |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
119 |
* Signature: (I)V |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
120 |
*/ |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
121 |
JNIEXPORT jint JNICALL Java_com_symbian_dbms_jdbc_DbmsStatement__1commit |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
122 |
(JNIEnv *, jobject, jint aPeer) { |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
123 |
DbmsStatement* statement = (DbmsStatement*) aPeer; |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
124 |
return statement->iConnection->iDatabase.Commit(); |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
125 |
} |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
126 |
|
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
127 |
/* |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
128 |
* Class: com_symbian_dbms_jdbc_DbmsStatement |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
129 |
* Method: _rollback |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
130 |
* Signature: (I)V |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
131 |
*/ |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
132 |
JNIEXPORT void JNICALL Java_com_symbian_dbms_jdbc_DbmsStatement__1rollback |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
133 |
(JNIEnv *, jobject, jint aPeer) { |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
134 |
DbmsStatement* statement = (DbmsStatement*) aPeer; |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
135 |
statement->iConnection->iDatabase.Rollback(); |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
136 |
} |
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
137 |
|
b538b70cbe51
Move rest of the swconfigmdw package components to oss repository.
terytkon
parents:
diff
changeset
|
138 |