Advertisement
Guest User

Untitled

a guest
Oct 24th, 2016
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 KB | None | 0 0
  1. JDBCDriver[
  2. "Name" -> "Microsoft SQL Server (MS6 driver)",
  3. "Driver" -> "com.microsoft.sqlserver.jdbc.SQLServerDriver",
  4. "Protocol" -> "jdbc:sqlserver://",
  5. "Description" -> "Microsoft SQL Server using Microsoft's jdbc 6.0 driver",
  6. "Location" -> "C:\Users\vriessc\AppData\Roaming\Mathematica\DatabaseResources\sqljdbc6.m"
  7. ]
  8.  
  9. DatabaseResourcesPath[]
  10.  
  11. {
  12. {"C:\Program Files\Wolfram Research\Mathematica\11.0\SystemFiles\Links\DatabaseLink\DatabaseResources", "DatabaseLink"},
  13. {"C:\Users\vriessc\AppData\Roaming\Mathematica\DatabaseResources", None},
  14. {"C:\ProgramData\Mathematica\DatabaseResources", None}
  15. }
  16.  
  17. conn =
  18. OpenSQLConnection[
  19. JDBC["Microsoft SQL Server (MS6 driver)", "ServerName"],
  20. "Properties" -> {"integratedSecurity" -> "true"},
  21. "Catalog" -> "DatabaseName"
  22. ]
  23.  
  24. SQLConnection[
  25. JDBC["Microsoft SQL Server (MS6 driver)", "wsrv2143"],
  26. "Location" -> "C:\Users\vriessc\AppData\Roaming\Mathematica\DatabaseResources\MyArbitraryConnectionName.m",
  27. "Name" -> "MyArbitraryConnectionName",
  28. "Catalog" -> "DatabaseName",
  29. "Description" -> "My descripion",
  30. "Password" -> "",
  31. "Properties" -> {"integratedSecurity" -> "true"},
  32. "ReadOnly" -> Automatic,
  33. "RelativePath" -> False,
  34. "TransactionIsolationLevel" -> Automatic,
  35. "UseConnectionPool" -> Automatic,
  36. "Username" -> ""
  37. ]
  38.  
  39. conn = OpenSQLConnection["MyArbitraryConnectionName"]
  40.  
  41. In[32]:= << DatabaseLink`
  42.  
  43. In[34]:= $Version
  44.  
  45. Out[34]= "11.0.1 for Mac OS X x86 (64-bit) (September 21, 2016)"
  46.  
  47. In[36]:= JDBCDrivers["Microsoft Access(UCanAccess)"]
  48.  
  49. Out[36]:JDBCDriver["Name" -> "Microsoft Access(UCanAccess)",
  50. "Driver" -> "net.ucanaccess.jdbc.UcanaccessDriver",
  51. "Protocol" -> "jdbc:ucanaccess://", "Version" -> 3.1,
  52. "Description" -> "Open-source Java JDBC driver implementation that allows Java developers and JDBC client programs to read/write Microsoft Access databases.",
  53. "Location" ->"/Applications/Mathematica11.0.1.app/Contents/SystemFiles/Links/DatabaseLink/DatabaseResources/accessjdbc.m"]
  54.  
  55. In[37]:= conn =
  56. OpenSQLConnection[
  57. JDBC["Microsoft Access(UCanAccess)",
  58. "/Users/damanjits/databaselink/Tests/AccessDB.accdb"]];
  59.  
  60. In[38]:= SQLCreateTable[conn, SQLTable["TEST"],
  61. SQLColumn["id", "DataTypeName" -> "integer", "PrimaryKey" -> True]]
  62.  
  63. Out[38]= 0
  64.  
  65. In[39]:= SQLTables[conn]
  66.  
  67. Out[39]= {SQLTable["TEST", "TableType" -> "TABLE"]}
  68.  
  69. Needs["DatabaseLink`"];
  70. openConn[]:=Block[
  71. {},
  72. If[$System==="Microsoft Windows (64-bit)",
  73. Return[OpenSQLConnection[JDBC["Microsoft SQL Server(jTDS)",
  74. "SERVERNAME/DATABASENAME"],
  75. "Username"->"USERNAME",
  76. "Password"->"PASSWORD"]]];
  77. If[$System==="Microsoft Windows (32-bit)",
  78. Return[OpenSQLConnection[JDBC["ODBC(DSN)",
  79. "DRIVER={SQL Server};"<>
  80. "SERVER=SERVERNAME;"<>
  81. "DATABASE=DATABASENAME"],
  82. "Username"->"USERNAME",
  83. "Password"->"PASSWORD"]]];
  84. Null
  85. ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement