Visual Studio Toolbox

Getting started with PHP, Java, and SQL Server on Linux

Getting started with PHP, Java, and SQL Server on Linux
5 (100%) 1 vote
(Video Transcript)
Hi there and welcome to Visual Studio Toolbox. I’m Dimitri and I’m really glad to be back on another episode. And I’ve got MJ and Mit here today. Hey guys, welcome.

>> Hi.

>> Hello, thank you.

>> So today we’re gonna be talking about SQL Server connectivity. We’re gonna do some Visual Studio Code demos and a lot of other cool stuff. But before we get going, I wanted the folks here, my guests, to introduce themselves and tell you all about what they do at Microsoft. So why don’t you go ahead?

>> Hi, I’m Andrea Lam, I’m a program manager on the SQL Server team. For the last two years or so, I’ve been concentrating on the connectivity space, particularly with C#, Java, and Ruby connectivity to SQL Server, both in the cloud and our cloud platforms.

>> Cool.

>> All right and hey guys, I’m Meet Bhagdev, I also work on the same team as Andrea

>> I work on connectors for ODBC, PHP, and Python.

>> Cool, well welcome to the show.

>> Thank you.

>> I met you guys about, I guess six months ago or so. And it was really great to see a team of people focused on connectivity. Cuz SQL Server, it’s a great product. I’ve used it quite a bit in .NET applications that I’ve worked on. I’ve actually had SQL as a backend for Java applications in the past as well. And if you really go really far back there was some other tech there but I think a lot of people are familiar with what SQL Server can do for the applications. And so they maybe will show them a bit more with languages and frameworks that you guys support. So do you wanna maybe kick it off a little bit and tell folks.

>> Yeah definitely.

>> [CROSSTALK].

>> So more and more our team’s been concentrating a little bit more on kind of the cross-platform storage for SQL Server. Now that SQL Server vNext CTP 1 is out, we now have support for Linux, both Ubuntu and REL. And we also have support for Mac via Docker. So this makes it much more important for us to have a solid cross-plat story across our entire connectivity landscape. And that includes traditional C# and Java, as well as new open-source languages, including Python, PHP and Ruby. So in our team, we kind of look at that for the entire SQL Server team, and we look at how do you bring all these awesome programming languages to have the connectivity towards SQL Server. And like I mentioned before, third party clouds, on premises, and our cloud platforms PaaS and all that kind of stuff. So what we’ve recently been working on more and more is actually our new website. We have a new getting started website.

>> [INAUDIBLE]

>> Yeah, it’s a homegrown PM type of thing. And we’ve really worked very hard on that. It basically just kind of walks you through all of the steps to get your prerequisites to get SQL Server running. Get all your language prerequisites, the connectors that you may need to connect to SQL Server and all that good stuff. And then we also walk you through some basic crud applications and then show you some cool features that we think you’ll enjoy to make your application a little bit better.

>> Cool, and one of the things that I want to the idea the WordCross platforms have been a little overloaded.

>> Yeah.

>> I think SQL is quite a bit in that terminology now. So let’s kind of talk through the various pieces. Of course, we’ve had SQL server as the engine, right. And that’s traditionally something you’ve only run in Windows. Eventually when Azure became a thing, we made SQL database, right. So we have something you can run Totaled in a managed way in the Cloud, or something you could run in Premises, or in some virtual machine. And then, we have, of course, have our tooling, which traditionally has been Windows. And that was kind of the story and then there were a bunch of drivers that we had made, or the community had made that allowed different languages and frameworks to connect up the SQL. And the biggest thing that we just released is the whole idea that okay, we’re gonna take the engine cross platform, and we’re gonna bring that to Linux. So that was our first cross platform play. And now we have the Visual Studio Code tooling that’s cross-platform.

>> Yeah.

>> And our driver story’s getting better and evolving and open sourcing in some cases. So those are three pillars and we’re gonna focus on the connectivity part. But I wanted to make sure folks in the audience understood there’s many aspects of cross-plat. We care about the tooling, connectivity, and the engine. And we’ll work with some of the support.

>> Yeah.

>> So why don’t you show folks the website that can get them oriented a bit?

>> Awesome, do you want to walk through it, or?

>> Yeah, sure. So as you can see, this is our getting started website. You can basically pick a language you want, so you have C#, Java, Node JS, PHP, Python, and R for now. We have all the OSes here, so let’s say you’re an OJS developer and you wanna get started on Mac, just click on it. And so you can see instructions to set up your environment, talk about how to install SQL Server, command line tool. Next, it’ll also show you how to create your first application. So the very simple application it’ll let you do simple queries which will be create, read, update and inserts. And lastly we’ll have a really cool Hero feature so we’re gonna talk about, actually, an ORM, and here, a feature called Column Store. It’s essentially a way to build indexes which will automatically or smartly realize where the data needs to be cached and make it a little faster. So we have a cool demo for that as well. And before we get started, I think we have a couple of demos we can show here.

So I guess we can do Java.

>> Yeah, let’s go ahead and do Java first.

>> Let’s do Java first.

>> Yeah, so one of the things I wanted to mention about the site, and we talked about this before, which is that the function should know that we fully support C++ and what was the other [INAUDIBLE]

>> Ruby.

>> Ruby. The website is just still a work in progress, right.

>> Yes.

>> We’re working in that. I don’t want folks to see this and say wait, [CROSSTALK] Ruby committed there. So you guys ready for the first demo?

>> Yeah, sure.

>> All right, so we’ll be right back and Andrea will begin the demo part of this. And back later to show some more demos as well.

>> Sounds good.

>> Awesome.

>> All right, well we’re back and ready for the demo so why don’t you go ahead, MJ.

>> Yeah, so today I’m gonna show you how to setup SQL Server on an Ubuntu 16.04 machine.

>> We’ll start with creating a simple Java application to help you kind of get started. You’ll get all the prerequisites that you need to run Java properly on Ubuntu 1604. And then I’ll show you kind of a simple application to connect to your database, run some simple operations. I’m gonna do all of this within VS code. And I’ll kind of use the Java language extension that’s available in the marketplace. Cool, and one of the things I wanted to kind of people is that we’re gonna show a very specific scenario, right?

>> Mm-hm.

>> So Java connecting to SQL Server on Linux which is our preview, but this scenario would work well just if you had Java connecting to SQL Database in the cloud, right, or SQL on-premises. This is just the example but we see SQL as a SQL anywhere thing.

>> It’s a platform.

>> Yeah it’s a platform, SQL is not different on Linux versus.

>> For sure.

>> Being in the cloud or whatever, it’s just that right now this is the demo that we want to [INAUDIBLE]

>> So yeah be it as simple as just changing the connection string parameters to point to wherever your SQL may be. cool.

>> Awesome.

>> All right.

>> Yeah, so let’s get started. So first steps, so we’re over on the website now, and I’m actually in the Java Ubuntu tab that we have set up here. So to set up your environment first, obviously one of the most important things we’re showing today is SQL server. So it’s kind of a few quick commands, so let me go ahead and I’ll open up VS code And VS Code has this really awesome integrated terminal built in. So I can actually run everything all within VS Code without having to switch to a different tool or anything like that.

>> Yeah, it’s a cool feature.

>> Yeah, so let’s see. Let’s go ahead. The first thing we’re going to do is actually just get into root, so let me switch that. I’ll paste this command over. Put in my password. Awesome, we’re in. And then, the next thing we’re gonna do is we’re actually just going to make sure that all of our keys are set up. So we’ll just add the keys that we need to actually access our repository where SQL server is. Paste that in So that’s done. And then switch back over. Grab, one more command. And, this is actually just the command to actually get the key for SQL Server. Paste that in. Paste never works, right.

>> Yeah.

>> There we go. All right, cool, all right, then we got that and then we’ll just exit our root. And the next thing would be is to actually just update all of the repository lists. So we’ll just do that really quickly. [BLANK AUDIO] Paste, it’s gonna go ahead and fetch a bunch of stuff, perfect that was fast.

>> Yeah, nice and quick.

>> And this is the most important step. So, this is actually going to get sequel server and install it for us from our package. So, let’s go ahead and paste that in. Awesome. So, the next thing is, do you wanna download this package, yes I do. And that’s just gonna quickly, run through and get the SQL Server package.

>> Nice.

>> On packing blah, blah.

>> Yes it’s really awesome to see Visual Studio running on a Mac. I still.

>> Yeah.

>> Every time I see it, I mean I don’t have a Mac and I’m not a Mac user much.

>> Mm-hm.

>> But. It’s just awesome, to see us being everywhere now.

>> Truly cross-plat.

>> Especially, with VS Code and such a cool little editor.

>> It’s, super powerful. Okay so I would say the next step we have to go through now is to actually setup SQL Server. So, that’s gonna actually create the password for our system admin. And then obviously we have to accept the license agreement and all that kind of stuff, so.

>> Sure.

>> Let’s set that up.

>> If nothing else we’re proving that the website really does have valid instructions.

>> Yes, yes.

>> When you’re cut and pasting, you’re showing them.

>> Okay so I’m gonna, let me choose a password that Meep can use after, as well. Confirm my password.

>> You can just mess it up for him. I’m sure he’ll enjoy typing in your password.

>> [LAUGH] Did it take it? Okay. Okay, perfect, sending it up.

>> Cool.

>> All right, let’s go ahead and start SQL Server. And we’ll just enable on boot, might as well. Awesome. So through all that, just set up SQL Server and it’s now running on an Ubuntu 1604 machine, which is pretty cool. So the next thing I’m going to do, just because we’re gonna need Java, is I’m actually going to install the Java runtime environment, the Java development kit. And I’m also gonna get Maven. Do you know what Maven is, Dimitris?

>> No, I keep hearing the word and nodding when people ask me. But I’m gonna be honest this time. No, I’m actually not sure.

>> So Maven is really awesome. So it’s what a lot of Java developers use to kind of build and manage their dependencies and their projects and stuff like that. So one of the biggest requests that we ever got for our Java driver, the JBC driver for SQL Server is that we weren’t kind of aware of all the native Java developers were. It may cause a little bit of friction cuz you’d have to go to the Microsoft download center. You’d have to get a TAR file or a ZIP file and then unpack that, and then point your project to that. And it kind of got a little bit complicated, and I could understand everybody’s frustration. So one of our biggest things now is we’ve actually put our JDBC driver up in Maven central repository. So now Java developers can easily go ahead and just grab the dependency, add it to their project and build their project with our JDBC driver.

>> Awesome, so now it’s just part of the natural flow.

>> Exactly.

>> For those developers [CROSSTALK].

>> So I just installed the JRE, we’re gonna grab the development kit as well. So we’ll need both of those to actually run all of our project. That’s grabbing that, and then the next thing we’ll need after that is to actually install Maven as well. So yeah, like I mentioned before, it’s used to build and manage all your dependencies, and it’s pretty cool cuz that means each project that you build, you can kinda specify your own dependencies. So let’s say, you’re switching from project to project, you don’t need the same dependencies, you can take those out and add them as you see fit.

>> Cool.

>> All right, so that’s done, we’ll install Maven. I think that’s cool is we still haven’t left VS code, Michael.

>> Yeah, I mean, having the terminal here is a really big deal, it makes it much easier.

>> Okay, so that’s gonna work through that, and then, we can just confirm that we have Maven by just running mvn-v. So, let’s just.

>> I like how you guys show the output. It’s always mysterious when you’re doing something the first time. You’re like, did the output show the right thing, or is there something in there that looks suspicious?

>> All right, cool. So, we’ve got Apache Maven 3.3.9. We’re using Java 8, and it’s put in our home directory. All right, cool, so, now we have everything that we need to start programming with Java on this machine here. So why don’t I go ahead and show you how to get a simple project started?

>> Let’s do it.

>> All right, so Maven’s cool cuz it actually has kind of sample projects for you to get started. So if you run a command like this, you specify the name of your project and a few other parameters. You can actually create a hello, world application without having to do anything. Oops, paste. So what this is going to do is it’s gonna set up the Maven project for me, it’s going to create a few files. The two most important files it’s gonna create is the dependencies file, that’s called pom.xml, and then an app.java file that’s kinda embedded in a few folders. So if I kinda wanted to show you that through the file explorer, just explain a little bit more. So that pom.xml file is probably one of the most important ones. So that’s where I’m gonna actually put the JDBC driver in it. I’ll show you that in a second. And then the next file that I’m gonna open is the app.java, and that’s where we’re gonna put all of our application code.

>> Cool.

>> So, one of the biggest things that we’ve been working on in terms of making sure that we have native support for Java developers is, like I mentioned before, putting the JDBC driver up on the Maven central repository. In order to do so, we wanted to also make sure that the source code was available for Java developers to see. So we’ve actually announced that we’ve open sourced the JDCB driver for SQL Server. All the source code is now on GitHub. You can actually go to the repository, filing issues you see. Java developers can make pull requests if they want. If there’s something that they think we’re missing, or they wanna help us clean up our code, those kind of things. So it’s really cool cuz our kind of goal for all that was to make sure we’re kind of closing in that feedback loop. Making sure that we’re able to respond to any issues as quickly as possible and stuff like that, so.

>> Yeah, I think one of the most important things to kind of sell our communities, that look, we’re moving things to open source because we wanna be part of the community. We want their feedback, their help. We wanna be transparent wherever possible, but we’re not abandoning drivers [CROSSTALK] we’re investing more than ever, I would say.

>> Yeah, and so I think, personally, for me, is in the last few years, I’ve just kind of learned more and more about what it is Java developers are looking for, and one of the biggest things is native install experiences. Decreasing that friction for them to get what they need and get started as quickly as possible. So that was one of our biggest goals, and I’m hoping that through this open sourcing work and getting up on Maven, that we can actually do that for them.

>> And how do you guys find out what Java developers want? What tactics do you use to get user feedback?

>> So I think what’s really cool is now that we’re on GitHub, we can actually send out poll surveys and stuff like that. So we can actually ask the community what it is that they’re looking for. What kind of scenarios that they’re trying to actually solve with their applications and their different work loads and stuff like that. Otherwise, it’s a lot of making sure that whatever we’re lighting up on SQL Server, VNext, all the support that is required on the client side, we’re also lighting up in all of our connectors and making sure that there’s support for those features.

>> Right, and I’m guilty of saying the word driver. You said connector, so we’re saying the same thing.

>> It’s the same thing.

>> It’s common language overload. And I think it’s very important to say, look, we know we’re revving all our products really fast, including SQL Server. Right, I would say probably speeding up, if anything else. And drivers need to keep up. And as community builds drivers that we sort of identify as top drivers, or as we build drivers, we’re gonna be looking to make sure that support gets in there, even if it’s our engineers doing the work. So I think that’s really a big step up.

>> Yeah, okay, so where did we leave off here? So what I was gonna do next, yes, I was going to add our JDBC driver, the one that’s in Maven, as a dependency to our project here. So, very simple to do. We also included that on our website. So the dependency is just right here. So I’m just gonna copy that code over. And I’m gonna paste that into my XML here, so still within the larger dependencies tag. So basically, we are in the group ID, it’s called com.microsoft.sqlserver. Our artifact or our jar is called mssql-jdbc. And the version I’m gonna use today is 6.1.0.jre8. I’m running Java 8 on this computer so we also have a jre7 jar available if you need it, so if you’re running an older version of Java, you can use that for your Java 7 project.

>> Cool.

>> All right, and one of the things that I like to do, personally, is I like to specify to Maven that I wanna build against Java.

>> 1.8.

>> Yeah, 1.8 cuz sometimes if you have conflicting versions on your computer, it kind of messes things up. So I like to specify that it’s against 1.8. If you wanna create a project that’s built in Java 8, but you’re compiling it against Java 7, you can also do that. Cuz Maven lets you do that.

>> Cool.

>> All right, so we’re going ahead and save that. So all we did was we added the JDBC driver as a dependency. And then we also specified to build against Java 8. All right, and then in our output Java, like I mentioned before, Maven kinda just created a sample project for us. So it actually created kind of a hello, world app for us, but I’m gonna replace this code with some of the sample code that we have here. And this sample code is basically going to create a database on my local host SQL Server, and it’s going to, yeah, create sample DB here. And then it’s going to create a table called employees. We’re gonna insert a few employees and those employees can have a name and a location, so you can see here in Nikita, India, Tom, and Germany. And then, we’ll insert another employee in, and then we’ll update one of the locations for one of the employees. And then we’ll just delete one of them, just to show you that we can actually walk through all the simple cred steps.

>> Yep, basic cred demo, but I think it does a good job to demonstrate all the basics there.

>> So let’s go ahead and just replace this code, paste that in. Awesome, so I have the Java language extension also included on my VS code here. Awesome, so we’ve saved that. And the next thing that we need to do is actually build our project. So it’s super simple to do. You just run a simple command mvn package, so.

>> Back to terminal.

>> Let’s make sure we’re in our proper, yep, we’re in the folder. And we’re gonna run mvn package. And that’s gonna build everything, it’s gonna grab a few things. This is the first time I’ve ever built on this machine. It’s also gonna run some simple tests, and it’s basically just gonna make sure are you specifying the right dependencies, is there anything in the pom file that doesn’t make any sense? Downloading a few more things.

>> We’re in a good connection here, it’s nice and fast.

>> All right. It should be done in a second.

>> Having the terminal window to play some music.

>> [LAUGH] All right, cool. It’s starting the test, awesome.

>> Yeah, there you go.

>> Build success, so what this does is I told it to actually output a jar. So you can build towards different things. So when the project is done building, it packages as a jar. All right, cool, so now we have a new jar created. It’s called SQLServerSample1.00.jar, and the next thing to do is actually run it. Let’s make sure we actually did something with the code that I put in, and that’s also very quick to do, so you just run Maven exact command, so I’ll paste that in as well. And basically, it points it to where the Java application is, so in my main class is in my app.java file so it’s pointing it to app.

>> Cool.

>> All right, so the first thing that’s-

>> You’re gonna roll?

>> Yeah, no.

>> No, it’s an exception.

>> What did it yell at?

>> Password issues?

>> Silly me, didn’t update my password.

>> It’s not your password? That would’ve been the easy one.

>> All right, we’re gonna run that one more time.

>> Real code, real code has to show this one exception, otherwise it doesn’t count.

>> This is the demo gods making fun of me. Okay, And we’ll run that again. So we repackaged it. Perfect. So the first thing it was doing was it was connecting the SQL Server, did that.

>> Yeah.

>> Then it created sample DB, that’s done. So the next thing it’s gonna do is actually populate that employees table with some data, so that’s done. And then we’re gonna insert a new employee. Done and then we’re gonna update Nikita’s location, done. And then we’re gonna delete someone, Jared. And then let’s go ahead and spit the rows back out. So we now have three employees in our table. So, you know, obviously I can that the app did that. But how do I make sure that it’s actually written to the database and I can actually see it?

>> Yeah. So how do we create?

>> So, yeah the cool thing about VS code is we have a new extension and MS-SQL extension for VS code so let me go ahead and show you how to query that. So let me open a new file. First thing I’m going to do is connect to my database. Yes, we need to sequel language and we’re going got create a new connection profile. So we are local and going pass in the username, my password. We will save the password and we’ll this local host connection. You can see it’s connecting perfect, right? It connects to the local host, were connected to master VP for now, we have logged in as, I’m got to switch to sample created it’s called VD. So, let’s make sure that I actually have stuff in my employees table. So I’m going to whip up a simple query. All right.

>> [INAUDIBLE] Awesome.

>> Okay, let’s see if that actually worked. Execute query. Awesome. Everything that I said I had in the terminal is actually written to the database and actually has been updated. So in a matter of minutes, I was able to create new Maven project, add the [INAUDIBLE] driver to my Java project, and then run some simple query commands.

>> Awesome.

>> Yeah.

>> One of the things we talked about earlier, and I think it’s good to banter a little bit about it, is the whole notion of look, we just showed a sample, right?

>> Yes.

>> This, we know this is very much demo style code, but we’re committed to SQL Server being a great experience in production environments for people, whether that’s making sure that the latest SQL Server features are in as we ramp up, and also supporting with issues. So what can you talk about from the support perspective, like how do we see these drivers People have problems, if they see issues in production, whatever, what’s the [INAUDIBLE]?

>> Obviously, the first line of command for us is our support engineers. Anybody who does have a problem, can contact us through the support team. Otherwise, we are available on Stack Overflow. We triage those questions pretty much every day. We go through all those as a PM team, making sure that we’re answering all the questions, whether it’s Stackoverflow, actually MSDN Forums. And then now that we’re in GitHub lemme go ahead and show you the project for the JWC driver. MSSQL, JWC. So one of the great things that I like about us being now on GitHub is Our we going, yeah. Our team now watches all the issues in poll requests very aggressively. And one of our big things for us is, our goal is to answer any issue or any new poll request within like 48 hours. We wanna make sure that we’re actually answering the issues in a way that the people that are actually following things, people who actually take the time to actually come to the repository are getting their questions answered.

So since we open sourced, which was a few weeks ago from today, we’ve actually aggressively been trying to close many pull requests. So we’ve closed 34, which has been really awesome. It’s kind of nice for us to start learning how to react to new things that come in on our GitHub. So I would say if you do have an issue one of the best places to do it if you don’t feel comfortable reaching out to a support engineer just simply following it on our GitHub and we’ll answer it as quickly as we can and we’ll have the conversations that we need. Otherwise, you can also check out on our website, we actually have a Gitter chat room that you can join. So if, for some reason you think there’s something wrong with the code, or also watching Gitter as well, and watching the conversations, and responding back as quickly as possible. And another way if, let’s say you don’t like to have instant messaging, you can also leave us a discuss comment at the bottom of the page, and we also look at that.

>> Cool, so it sounds like you guys are monitoring all the big-

>> Yeah.

>> Typical rough channels-

>> Yep.

>> And the forums, you’ve got your issues in GitHub, you’ve got your support number, people you can call, the traditional Microsoft CTS, customer technical support number, and you’re even watching comments on the bottom of the pages.

>> We’re everywhere.

>> You’re everywhere. Cool, all right, so, is that all you’re gonna show for your demo today?

>> Yeah, that’s what I’m gonna show today, so, just the overview. Open source [INAUDIBLE] driver. You can now access everything through the Maven central repository. And that’s kind of the biggest things that we’ve been adding towards, making sure that Java developers can use SQL Server.

>> Cool. All right. We’ll get [INAUDIBLE] back on and we’ll get into the next demo.

>> Sounds good. Thank you.

>> We’ll be right back. All right. We’re back and we’ve got our next demo. [CROSSTALK]

>> You were hiding in the back there.

>> I was, yeah.

>> Almost knocked over the camera [INAUDIBLE]

>> A couple times, yeah. [LAUGH]

>> All right. What are you going to show us?

>> Similar to what Andrea showed for java, we’ll be making a lot of improvements on the PHP front. RPHP drivers also on GitHub. It’s fully opened stores and we recently added a couple of really cool things. So we now support Lennox where we didn’t use to before. Approximately two months ago we supported 15-10 and 1604 and we support red hat 6 and red hat 7 which is kind of like maven which is a package manager that lets you install pastry packages directly linking it to the run time. So you don’t have to get an SO file, put it somewhere, things like that, you just build it from source, link it to PHP and PHP knows where to read it from. So that’s kind of the MPM or the App Get of the PHP world. So in my demo I’m just really gonna quickly try to install the diver, on my fresh Ubuntu box, and run a sample code. And see if we can add some clarities, and see if the VS Code extension can pick it up.

>> All right, let’s do it.

>> All right, so jump right into the demo. So I’m gonna use the same website that we have. We’ve already set up the environment, so I’m gonna go ahead and skip that step. I’m gonna go straight to creating the PHP application. So let’s see, the first things what you need to do is we need to add the ODBC driver. So the way our PHP driver works that it sits on top of the ODBC driver, cuz ODBC driver is typically more performant, it knows how to talk to SQL. It has all the features. And we’re really gonna go ahead and add the driver.

>> It’s one of our oldest driver’s right?

>> It is one of our oldest drivers. And that is also available on Linux now.

>> Awesome.

>> Yeah.

>> Which drivers support which operating systems and where we can make all this stuff work. It’s awesome. All right? So I’m going to go ahead and add the repository. And then we’re going to make sure we have the key set up. As you can see, I’m literally copy/pasting from the website.

>> Yep. The real instructions do work.

>> Yes. Give it a couple seconds. There you go. And we just ran an update to make sure repository list is updated with the recent one that you just added. And then all you need to do is appget and reinstall SQL and Linux that’s essentially it. In terms of the prerequisites. It’s going to ask you, okay. Yes. All right, seems like our ODBC driver was installed and next we’ll install the PHP connector, or driver, as people like to call it. All we’ll be doing here is just pecl install sqlserv The version I’m gonna use today is 4.0.7, and pdo_sqlsrv 4.0.7. They both complement each other. PDO is kind of an object oriented form that’s linked to PHP, so we recommend you to use whichever one you’re more comfortable with, but we have a story for both.

>> Okay.

>> So it’s absolutely up to you, they can exist side by side.

>> Cool. So I’m gonna just install both. It seems like we don’t have pecl install, so let’s make sure we do get that. Instructions to do that are also on our website. So you just go ahead and copy.

>> The dependency for the dependency.

>> Yeah. We actually didn’t install PHP. It’s my bad.

>> No problem.

>> All right.

>> We’re showing real world approaches.

>> Exactly. Yes.

>> I did most of the ones. [LAUGH] So take a few seconds while that’s installing, I’ll talk about the application we’re gonna show you today. So similar to what we showed in Java this is PHP script. Very simple you can and run it using a patchy on the browser or you can run it from command line. I’m just gonna run it through the S code, trying to just show the end-to-end story there.

>> Don’t forget to change your password this time.

>> I will not forget that.

>> You learned that from the last demo.

>> Yes. And what you’re gonna do is you’re gonna insert a new row into the table. So we’re gonna insert Jake, update Nikita’s location and delete Jared from our table, and we’re gonna use the same employee’s table. We’re gonna spice things up a little. We’re gonna create a new schema. And we’re gonna use the VS code tool, the MS SQL extension to do all of this, kind of just to show you can do more than just select. You can actually do everything a regular tool would be able to do.

>> Yeah, I mean I think VS code is a certain kind of editor, a certain kind of tool, right? It’s not Visual Studio, it’s not SQL Server Management Studio, it’s an editor, a code editor. But even in that state by the limitations by design, we have quite a bit of features [INAUDIBLE]

>> Exactly, it’s very powerful, yeah. All right, so I’m just gonna go ahead and run this script, which will create the schema for us.

>> So you’re connected, it shows in the bottom right. So you’re still connected to the same-

>> Yes.

>> SQL as before.

>> Absolutely. So as you can see, I’m connected to the local host, the SQL Server that we just installed, using sample DB and the SA user name. So kind of go ahead and right click, Execute Query, all right, there you go. So we just created a new table with a schema. So TestSchema.Employees and we have three employees that as you can see we have Jared, Nikita and Tom. Now, let’s go back to our website and see what’s next. So as you can see, we’ve never installed our driver.

>> Yeah.

>> Let’s go ahead and.

>> Our pre-requisite is missing.

>> Yes. Copy that. All right, so it downloaded our source code. It’s gonna do a bunch of Build’s work, and it’s gonna do a bunch of linking work as you can see. It’ll take about 5 to 10 seconds, typically.

>> I used to program in PHP a long time ago, it was one of my, I would say maybe like my third project in my life that was given. I started with ASP, classic ASP, back in the day.

>> Okay.

>> We just had this PHP project that was just sitting there and needed some maintenance work and I was like, how hard could it be [LAUGH]? It took me a bit, I was able to patch up their site. But PHP is quite, I would say I had a pleasant experience. I think as some people, languages are religious [CROSSTALK]

>> It’s one of those languages that either you love it or you hate it.

>> I came away with a fine kind of experience.

>> All right, cool. So, as you can see, it says build process completed successfully, install okay. And now it’s telling us to add our extension to the ini file. It’s important because PHP needs to know that you just added these extensions, that it need to load it. So, the instructions to do that are also on our website, so I’m just gonna copy these. Let’s see, copy them one by one. All right, so we added it to a couple of our ini files. And then we have two variants so we have to do it twice. All right, so as you can see we’ve four echo statements, all it’s saying, add this extension to my PHP.ini file. And you can confirm that you actually have PHP installed by running php -v. As you can see, we’re running v7.0.8 and that’s the one where we added the driver. And we’re pretty much set to run our first application now. So if I scroll down further.

>> So you’re just gonna grab the code?

>> Literally, yes, I’m gonna go and,

>> There you go. Go ahead and copy that code and paste it here. And I also have the PHP extension for VS code here

>> I guess it’s not picking it up because there’s no file extension or something.

>> Yeah, it got to save it as something, so I’m gonna use the same folder Andrea had, going to call it, sample.php. All right, there you go. So it picked up the colors and things like. Let’s see if we can go ahead and run this right now. All right, there you go. It says, I inserted one new row, updated the location for Nikita, deleted Jared, read the data and now we have three rows. Let’s go ahead back to our VS Code extension for SQL and see if it actually works. So I’m gonna run the Select Query. And there you go. So Nikita now lives in Sweden. Jared is no longer in the table cuz we deleted him. And you have Tom and Jake. And that pretty much sums it up. As you can see-

>> Is Jared wearing a red shirt?

>> I think so.

>> Yeah, it seems like it.

>> When we were working on the website, we were like, okay, we have four names here. Who should we be giving?

>> Somebody has to die in a way mission, that’s the rule.

>> Yeah, poor Jared.

>> Yeah.

>> He took the brunt there. But yeah, as you can see, in the matter of minutes I would say, you got the PHP driver, its dependencies. You installed PHP from the go because we didn’t have it. Run a simple app, did a few queries and verified our results using the VS code extension.

>> Awesome.

>> Similar to the JDBC project, the PHP project is also open source, so let’s just search for msphpsql. All right, bingo. So this is our GitHub project. You can come to our Issues tab and go ahead and just file an issue. As you can see we very closely monitor it. We’ve had a bunch of issues closed, a bunch open. If you have any questions, just go ahead and hit the New Issue button, leave us a comment. We also send a bunch of surveys here. Kind of just asking, hey, what features do you guys want? So we sent one out recently and people were like, I want all these encrypted. So we’re gonna start building that in the next couple months.

>> I’m not surprised there, it’s a good feature.

>> It’s a good feature, so that’s one of the cool features that we’re adding, kind of just making sure all their drivers are at par with the best features, the hero features. But yeah, it’s a pretty cool driver, if you have any other questions, feel free to leave us an issue. Or as Andrea said, join our chatroom, we monitor that pretty actively as well.

>> Cool, well, I think the big takeaway here is, look, we are very serious about our connective story, we want to enable all these languages and frameworks to connect, we’re committed to supporting them. So if you have mission critical stuff, call our CTS number, if you have issues and then if you have suggestions, if you want to submit some code changes you got a lot of places.

>> Absolutely.

>> We’re in for a whole list of places too.

>> Totally, yeah, we’re all about embracing cross platform, open source and making sure the developers succeed in what they wanna do with SQL. Cuz that’s one of the places where we’ve typically been known to not be that friendly and we’re trying to change that right now.

>> Yeah, it’s a whole Microsoft and SQL is part of that.

>> Absolutely.

>> So it’s really awesome. Cool, did you want to show anything else or?

>> No, that’s pretty much it. I guess to just end it at, if you guys have any questions, you can e-mail Andrea or me. Our e-mail address is andrela@microsoft.com and meetb@microsoft.com. Or you can even tweet at us, our Tweeter handles are up on the screen. And just a few call to actions, please check out our developer tutorials, as you can see they’re end to end. You’ll literally be able to install SQL on Mac, Windows, or Linux. Get the connectors, run simple examples and try out a cool feature, which is columnstore. Pretty cool, go to our repositories, file issues, make us work. Make us earn our paycheck, I would say. And that’s pretty much it. Thank you all for listening.

>> All right, well, appreciate you coming on and I hope folks enjoyed this episode. We’re gonna have more episodes in SQL. We have one coming up where we’re gonna look at VS code a bit deeper. So Andrea is gonna come back on probably. And if you have things you wanna see or talk about, put it in the comments. We’re always ready to go and respond to your feedback. And I’ll make sure all these emails and slide links are in the show notes as well. So thank you very much for coming on.

>> Thanks Jimmy.

>> Andrea’s hiding in the back there. Thank you for being on there and we’ll see you guys next time on Visual Studio Toolbox.

>> All right, thank you guys, thank you.

 

Read the video

In this episode, Dmitry is joined by Meet Bhagdev and Andrea Lam, who show us how to get started with programming apps in PHP and Java connecting to SQL Server on Linux. PHP and Java both have open sourced connectors that can be used by applications to connect to SQL Server anywhere (on-premises or in the cloud). This includes the recently released SQL Server on Linux and we’ll show you some demo’s using Visual Studio Code and the newly released SQL Server extension.

Resources:


Leave a Comment

Your email address will not be published. Required fields are marked *

Loading...
1Code.Blog - Your #1 Code Blog