C# mongod- insert fails with "unable to connect to server, attempted to read past the stream" - mongodb-.net-driver

I am able to create a successful connection to a remote mongodb server and database. When I try and insert the document into a collection I get the following error:
Unable to connect to server xxx.xxx.x.xx:28017: Attempted to read past the end of the stream..
after a little lag. I am not sure what the issue is if the connection seems fine.
server = New MongoClient("mongodb://admin:password#xxx.xxx.x.xx:28017/").GetServer
db = server.GetDatabase("TestDB")
mongoC = db("TestCpo")

Have you made sure that Mongo is up and running? Open up a command line, navigate to the location of your mongo installation then to the bin directory, type in "mongod". This will start up the mongo server, you need to have the mongo server up and running before you can do anything with it.
It's also useful to add the path to your environment variables so that it can be set up easier.
Another thing you could do is use
Process.Start(#"C:\[Directory of the mongo installation]\bin\mongod.exe");
(this is probably more useful if you want to start Mongo under test conditions)

Related

Create an H2 Database from the console

I would like to run H2 on my local host (Windows), and create a new database.
To do so, I have dowloaded the zip file from http://www.h2database.com/html/main.html, unzipped it, then run the bin/h2.bat script. I have not used the windows installer, as the machine I will be running later on does not grant me installation privileges.
The console was successfully opened on the 8082 port, but I could not create any database, failing with Database "C:/Users/PC/test" not found [90013-198] 90013/90013. I have tried many variations, to no avail.
The documentation states that a database should be created automatically if it does not exist, but indicates it cannot be done so from the H2 console (http://www.h2database.com/html/tutorial.html#creating_new_databases).
However, the documentation does not provide an alternate way to create a database, either by running the jar with additional parameters, or by another utility.
I feel pretty dazed right now. How do I properly create a new database in H2? I would like a normal database, persisted on disk, not an in-memory one.
I would suggest that this does not work in version 198
You could download an older version (I used 196) to create the databse and then switch back to 198 to open the database.
I have managed to run it by using the following command line:
java -cp h2-1.4.198.jar org.h2.tools.Server -tcp -pg -web
I must have missed something in the documentation, sorry about this.

RethinkDB does not create help and help_internal databases

I am trying to use the Horizon framework by the RethinkDB team but I am facing startup issues with Rethink. I try to start up the server with the command
rethinkdb --http-port 8082
all works fine but when I run my app.js where horizon is embedded, I obtain the error.
error: Connection to RethinkDB terminated: Error: The database help_internal does not exist.Run hz set-schema to initialize the database, then start the Horizon server.
I ran the command above and it creates a rethinkdb_data folder and whenever I restart the server, it gives me the same error.
You need to tell hz set-schema how to connect to the RethinkDb server you're running, otherwise it will create its own in your current working directory. You can pass it the same connection options you pass to hz serve.
I also got this error. It can be confusing because in dev mode of horizon it usually creates these databases for you.
In prod, however, you must create the databases yourself. To do this it is as simple as logging into RethinkDB's admin interface, click on the "Tables" navigation item then clicking the "+ Add Database" button. Create two databases called 'help' and 'help_internal' assuming that your horizon project_name name is 'help'.
Note that in addition to creating the databases I've described you may also need to create tables in these databases. This is where you should use get-schema on your dev server (to dump the current schema to disk) and set-schema on your prod server (to create the tables needed to support the schema).
For some npm tasks that accomplish the getting and setting of schema you can see here.

Mule Connect to remote flat files

I am new to Mule and I have been struggling with a simple issue for a while now. I am trying to connect to flat files (.MDB, .DBF) located on a remote desktop through my Mule application using the generic database connector of Mule. I have tried different things here:
I am using StelsDBF and StelsMDB drivers for the JDBC connectivity. I tried connecting directly using jdbc URL - jdbc:jstels:mdb:host/path
I have also tried to access through FTP by using FileZilla server on remote desktop and using jdbc URL in my app - jdbc:jstels:dbf:ftp://user:password#host:21/path
None of these seem to be working as I am always getting Connection exceptions. If anyone has tried this before, what is the best way to go about it? Connecting a remote flat file with Mule? Your response on this will be greatly appreciated!
If you want to load the contents of the file inside a Mule flow you should use the file or FTP connector, i don't know for sure about your JDBC option.
With the File connector you can access local files (files on the server where mule is running), you could try to mount the folders as a share.
Or run an FTP server like you already tried, that should work.
There is probably an error in your syntax / connection.
Please paste the complete XML of your Mule flow so we can see what you are trying to do.
Your usecase is still not really clear to me, are you really planning to use http to trigger the DB everytime? Anyway did you try putting the file on a local path and use that path in your database url. Here is someone that says he had it working, he created a separate bean.
http://forums.mulesoft.com/questions/6422/setting_property_dynamically_on_jdbcdatasource.html
I think a local path is maybe possible and it's better to test that first.
Also take note of how to refer to a file path, look at the examples for the file connector: https://docs.mulesoft.com/mule-user-guide/v/3.7/file-transport-reference#namespace-and-syntax
If you manage to get it working and you can use the path directly in the JDBC url, you should have a look at the poll scope.
https://docs.mulesoft.com/mule-user-guide/v/3.7/poll-reference
You can use your DB connector as an inbound endpoint when wrapped in a poll scope.
I experienced the same issue when connect to Microsoft Access Database (*.mdb, *.accdb) using Mule Database Connector. After further investigation, it's solved by installing Microsoft Access Database Engine
Another issue, I couldn't pass parameter to construct a query as same as I do for other databases. e.g.: SELECT * FROM emplcopy WHERE id = #[payload.id]
To solve this issue:
I changed the Query type from Parameterized into Dynamic.
I generated the query inside Set Payload transformer (generate the query in form of String, e.g.: SELECT * FROM emplcopy WHERE id = '1').
Finally, put it into the Dynamic query area: #[payload]

mongo shell not showing all dbs

Good Day.
I've been developing with meteorJS which uses mongodb. No problems there. I've been using the mongo shell to access the database on my dev machine (osx 10.11). This is my first project with mongo and when the shell would load, it would connect to db.test and I'd always show dbs and get the list of database, then use myApp.
Yesterday whenever I go into the shell and I type show dbs the only one shown is local 0.078GB. However my app is still working and pulling and pushing data to the database.
I've checked the dbpath in the mongod.conf and that seems ok. I'm not entirely sure about the exact order of things, but two things where different (I'm not sure if these happened prior to the show dbs not showing everything or after, and I'm not sure which came first):
when loading the mongo shell I was getting this error:
WARNING: soft rlimits too low. Number of files is 256, should be at least 1000"
I followed these directions which seemed to stop that error from appearing (https://github.com/basho/basho_docs/issues/1402 )
I use Meteor Toys and for the first time I update user.profile.companyName (which is a custom field within the standard profile from within the Meteor Toys widget.
Just odd that the app can still access the database and collections, but that the mongo shell doesn't show. I've update mongod via brew upgrade mongodb from 3.0.2 to 3.0.7 to no avail.
Any ideas?
If you want to use the regular mongo console you have to specify the port to be 3001 for meteor apps instead of the default 27017. Otherwise it's much simpler to just type meteor mongo and connect that way. Then you can type 'show collections' and it will show them all just like normal.
MongoDB do not show the database unless if there is minimum of one collection with a document in it.
Refer to this link

what is the GROOVY connection string to an JDBC database with SSPI = True? I am running this from SoapUI Free version

I'm trying to do this:
import groovy.sql.Sql
def sql = Sql.newInstance(
url:'jdbc:sqlserver://localhost\\myDB',
user:'server\user', //this I don't think I need because of SSPI
password:'password',
driver:'com.microsoft.sqlserver.jdbc.SQLServerDriver',
SSPI: 'true'
)
The problem I'm having is that this connection is just timing out. I can ping the machine. I can also connect to the database with Managment Studio logged into my SSPI user (or whatever you call it, I start the Management Studio with a different user)
So I've tried that with my SoapUI as well, started the program as a different user, but I still time out when I initiate the connection. So something is very wrong with my connection string and any help would be appreciated.
P.S. Yes, I don't know what's up with the \ backslashes after the URL to the server, I guess it indicates that it's at the root. If I don't use them I get a message that I'm on the incorrect version.
And then we found the answer..... First of all I had the wrong JDBC driver installed. You need to head over to microsoft to get the real deal:
https://www.microsoft.com/en-us/download/details.aspx?id=11774
Then you need to unpack this one, place the 4 or 4.1 version in your bin directory of SoapUI. (You are apparently supposed to use Lib/Ext, but that doesn't work for me)
Then, since we are trying to use SSPI or Windows Authentication, to connect to the SQL server, you need to place the sqljdbc_auth.dll from the driver/enu/auth folder. This is used in one of your path's or in SoapUI Lib folder. Remember to use the 32 bit dll for 32 bit SoapUI!!! I did not since my system is 64.....
After this, I used this string, but now you have the setup correct, so it should work fine as long as you remember to start SoapUI up using the correct windows user. (Shif-right click - start as different user - use the same user you have started the SQL server with)
Again, I wasn't completely aware of this from the start (yes, total newbie here) and it failed.
Finally, when you have done all this, this is the string that works - and probably a lot of derivatives since the failing part here were the driver and dll.
def sql =Sql.newInstance("jdbc:sqlserver://localhost;Database=myDB;integratedSecurity=true","com.microsoft.sqlserver.jdbc.SQLServerDriver")

Resources