Advertisement
Guest User

Untitled

a guest
Mar 21st, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. --- RJDBC0.2-6/R/class.R 2017-02-07 21:38:59.000000000 +0100
  2. +++ RJDBC0.2-6mod/R/class.R 2017-03-22 02:39:42.000000000 +0100
  3. @@ -37,18 +37,12 @@
  4. setMethod("dbUnloadDriver", "JDBCDriver", def=function(drv, ...) FALSE)
  5.  
  6. setMethod("dbConnect", "JDBCDriver", def=function(drv, url, user='', password='', ...) {
  7. - jc <- .jcall("java/sql/DriverManager","Ljava/sql/Connection;","getConnection", as.character(url)[1], as.character(user)[1], as.character(password)[1], check=FALSE)
  8. - if (is.jnull(jc) && !is.jnull(drv@jdrv)) {
  9. - # ok one reason for this to fail is its interaction with rJava's
  10. - # class loader. In that case we try to load the driver directly.
  11. - oex <- .jgetEx(TRUE)
  12. - p <- .jnew("java/util/Properties")
  13. - if (length(user)==1 && nchar(user)) .jcall(p,"Ljava/lang/Object;","setProperty","user",user)
  14. - if (length(password)==1 && nchar(password)) .jcall(p,"Ljava/lang/Object;","setProperty","password",password)
  15. - l <- list(...)
  16. - if (length(names(l))) for (n in names(l)) .jcall(p, "Ljava/lang/Object;", "setProperty", n, as.character(l[[n]]))
  17. - jc <- .jcall(drv@jdrv, "Ljava/sql/Connection;", "connect", as.character(url)[1], p)
  18. - }
  19. + p <- .jnew("java/util/Properties")
  20. + if (length(user)==1 && nchar(user)) .jcall(p,"Ljava/lang/Object;","setProperty","user",user)
  21. + if (length(password)==1 && nchar(password)) .jcall(p,"Ljava/lang/Object;","setProperty","password",password)
  22. + l <- list(...)
  23. + if (length(names(l))) for (n in names(l)) .jcall(p, "Ljava/lang/Object;", "setProperty", n, as.character(l[[n]]))
  24. + jc <- .jcall("java/sql/DriverManager","Ljava/sql/Connection;","getConnection", as.character(url)[1], p)
  25. .verify.JDBC.result(jc, "Unable to connect JDBC to ",url)
  26. new("JDBCConnection", jc=jc, identifier.quote=drv@identifier.quote)},
  27. valueClass="JDBCConnection")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement