Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.30 KB | None | 0 0
  1. package VB;
  2.  
  3. import VBA.Interaction;
  4. import VBA.Strings;
  5. import java.sql.*;
  6.  
  7. // Referenced classes of package VB:
  8. // IJabacoClass
  9.  
  10. public class DataBase
  11. implements IJabacoClass
  12. {
  13.  
  14. private void Class_Initialize()
  15. {
  16. Throwable Err = null;
  17. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  18. _L1:
  19. return;
  20. _L2:
  21. Interaction.MsgBox((Throwable)Err);
  22. goto _L1
  23. Err;
  24. goto _L2
  25. }
  26.  
  27. public boolean Connect(String url)
  28. {
  29. boolean Connect;
  30. Throwable Err;
  31. Connect = false;
  32. Err = null;
  33. myCon = null;
  34. _L5:
  35. myCon = DriverManager.getConnection(url);
  36. _L6:
  37. if(myCon == null) goto _L2; else goto _L1
  38. _L2:
  39. _L7:
  40. Connect = false;
  41. goto _L3
  42. _L1:
  43. _L8:
  44. Connect = true;
  45. _L3:
  46. _L4:
  47. return Connect;
  48. Err;
  49. goto _L4
  50. goto _L5
  51. goto _L6
  52. goto _L7
  53. goto _L3
  54. goto _L8
  55. goto _L3
  56. }
  57.  
  58. public boolean Connect(String url, String user, String password)
  59. {
  60. boolean Connect;
  61. Throwable Err;
  62. Connect = false;
  63. Err = null;
  64. myCon = null;
  65. _L5:
  66. myCon = DriverManager.getConnection(url, user, password);
  67. _L6:
  68. if(myCon == null) goto _L2; else goto _L1
  69. _L2:
  70. _L7:
  71. Connect = false;
  72. goto _L3
  73. _L1:
  74. _L8:
  75. Connect = true;
  76. _L3:
  77. _L4:
  78. return Connect;
  79. Err;
  80. goto _L4
  81. goto _L5
  82. goto _L6
  83. goto _L7
  84. goto _L3
  85. goto _L8
  86. goto _L3
  87. }
  88.  
  89. public boolean ConnectMDB(String path)
  90. {
  91. boolean ConnectMDB;
  92. Throwable Err;
  93. ConnectMDB = false;
  94. Err = null;
  95. ConnectMDB = Connect(Strings.StrCat("jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=", path));
  96. _L1:
  97. return ConnectMDB;
  98. _L2:
  99. Interaction.MsgBox((Throwable)Err);
  100. goto _L1
  101. Err;
  102. goto _L2
  103. }
  104.  
  105. public boolean ConnectMDB(String path, String user, String password)
  106. {
  107. boolean ConnectMDB;
  108. Throwable Err;
  109. ConnectMDB = false;
  110. Err = null;
  111. ConnectMDB = Connect(Strings.StrCat("jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=", path), user, password);
  112. _L1:
  113. return ConnectMDB;
  114. _L2:
  115. Interaction.MsgBox((Throwable)Err);
  116. goto _L1
  117. Err;
  118. goto _L2
  119. }
  120.  
  121. public boolean ConnectDSN(String dsn)
  122. {
  123. boolean ConnectDSN;
  124. Throwable Err;
  125. ConnectDSN = false;
  126. Err = null;
  127. ConnectDSN = Connect(Strings.StrCat("jdbc:odbc:", dsn));
  128. _L1:
  129. return ConnectDSN;
  130. _L2:
  131. Interaction.MsgBox((Throwable)Err);
  132. goto _L1
  133. Err;
  134. goto _L2
  135. }
  136.  
  137. public boolean ConnectDSN(String dsn, String user, String password)
  138. {
  139. boolean ConnectDSN;
  140. Throwable Err;
  141. ConnectDSN = false;
  142. Err = null;
  143. ConnectDSN = Connect(Strings.StrCat("jdbc:odbc:", dsn), user, password);
  144. _L1:
  145. return ConnectDSN;
  146. _L2:
  147. Interaction.MsgBox((Throwable)Err);
  148. goto _L1
  149. Err;
  150. goto _L2
  151. }
  152.  
  153. public ResultSet ExecuteStatement(String sql)
  154. {
  155. ResultSet ExecuteStatement;
  156. Throwable Err;
  157. Statement myStmt;
  158. ExecuteStatement = null;
  159. Err = null;
  160. myStmt = myCon.createStatement();
  161. ExecuteStatement = myStmt.executeQuery(sql);
  162. _L1:
  163. return ExecuteStatement;
  164. _L2:
  165. Interaction.MsgBox((Throwable)Err);
  166. goto _L1
  167. Err;
  168. goto _L2
  169. }
  170.  
  171. public boolean Execute(String sql)
  172. {
  173. boolean Execute;
  174. Throwable Err;
  175. Statement myStmt;
  176. Execute = false;
  177. Err = null;
  178. myStmt = myCon.createStatement();
  179. Execute = myStmt.execute(sql);
  180. _L1:
  181. return Execute;
  182. _L2:
  183. Interaction.MsgBox((Throwable)Err);
  184. goto _L1
  185. Err;
  186. goto _L2
  187. }
  188.  
  189. public int ExecuteUpdate(String sql)
  190. {
  191. int ExecuteUpdate;
  192. Throwable Err;
  193. Statement myStmt;
  194. ExecuteUpdate = 0;
  195. Err = null;
  196. myStmt = myCon.createStatement();
  197. ExecuteUpdate = myStmt.executeUpdate(sql);
  198. _L1:
  199. return ExecuteUpdate;
  200. _L2:
  201. Interaction.MsgBox((Throwable)Err);
  202. goto _L1
  203. Err;
  204. goto _L2
  205. }
  206.  
  207. public Connection $Connection()
  208. {
  209. Connection $Connection;
  210. Throwable Err;
  211. $Connection = null;
  212. Err = null;
  213. $Connection = myCon;
  214. _L1:
  215. return $Connection;
  216. _L2:
  217. Interaction.MsgBox((Throwable)Err);
  218. goto _L1
  219. Err;
  220. goto _L2
  221. }
  222.  
  223. public Connection $Parent()
  224. {
  225. Connection $Parent;
  226. Throwable Err;
  227. $Parent = null;
  228. Err = null;
  229. $Parent = myCon;
  230. _L1:
  231. return $Parent;
  232. _L2:
  233. Interaction.MsgBox((Throwable)Err);
  234. goto _L1
  235. Err;
  236. goto _L2
  237. }
  238.  
  239. public DataBase()
  240. {
  241. initVars();
  242. Class_Initialize();
  243. }
  244.  
  245. private void initVars()
  246. {
  247. myCon = null;
  248. }
  249.  
  250. private Connection myCon;
  251. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement